MySQL資料庫的基本操作,mysql基本操作

來源:互聯網
上載者:User

MySQL資料庫的基本操作,mysql基本操作

一、查看所有資料庫

mysql> show databases;+--------------------+| Database           |+--------------------+| information_schema || mysql              || performance_schema || wms                |+--------------------+

其中,前三者是資料庫內建的三個庫。

二、建立資料庫的基本文法

1. CREATE DATABASE  database_name; // database_name是要建立的資料庫的名稱,該名稱不能與已經存在的資料庫重名。

例如:

mysql> create database db_test;
2. 資料庫建立好以後,可以使用 SHOW CREATE DATABASE聲明查看資料庫的定義。

例如:

mysql> show create database db_test\G;*************************** 1. row ***************************       Database: db_testCreate Database: CREATE DATABASE `db_test` /*!40100 DEFAULT CHARACTER SET latin1 */

3. 使用 SHOW DATABASES 命令查看所有資料庫:

mysql> show databases;+--------------------+| Database           |+--------------------+| information_schema || db_test            || mysql              || performance_schema || wms                |+--------------------+

三、刪除資料庫

1. 文法

DROP DATABASE  database_name; //database_name為要刪除的資料庫的名稱,如果該資料庫不存在,則刪除出錯。

2. 樣本

mysql> show databases;+--------------------+| Database           |+--------------------+| information_schema || db_test            || mysql              || performance_schema || wms                |+--------------------+mysql> drop database db_test;Query OK, 0 rows affected (0.05 sec)mysql> show databases;+--------------------+| Database           |+--------------------+| information_schema || mysql              || performance_schema || wms                |+--------------------+

3. 注意: 使用DROP DATABASE命令時要非常謹慎,在執行該命令時,MySQL不會給出任何提醒確認資訊,DROP DATABASE刪除資料庫以後,資料庫中儲存的所有資料表和資料也一同被刪除,而且不能恢複。


四、選擇當前資料庫
文法
USE database_name;

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

如果你們有更好的建議,請發郵件到我私人郵箱: david.louis.tian@outllook.com

著作權@: 本文系本人原創,轉載請標明出處,謝謝

MYsql資料庫的操作?

你要做什嗎?不明白
 
用命令l提示符操作mysql資料庫的

create database newdatabasname;
use newdatabasname;
create table newtablename (col1 char,
col2 integer) engine ='innodb' chareset utf_gerneral_ci;
insert into newtable valeus ('',1);
delete from newtable where continationid;
update newtable
set col = value
from newtable
where continationid
;
select * from newtabale where continationid;
匯出
SELECT * INTO OUTFILE 'data.txt'
FIELDS TERMINATED BY ','
FROM newtable
;
匯入;
LOAD DATA INFILE '/data.txt'
-> INTO TABLE newtable LINES STARTING BY "xxx";
 

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.