前面爲命令,後面"[]"中內容爲該命令的作用。
net start mysql [啓動MySQL服務]
net stop mysql [關閉MySQL服務]
mysql -uroot -p12345678 [連接數據庫]
show databases [顯示當前存在的數據庫]
use 數據庫名 [選擇要使用的數據庫]
create 數據庫名 [新建一個數據庫]
show tables [顯示當前數據庫中已存在的表]
create table person
(
id varchar(32) not null primary key,
name varchar(20) not null,
password varchar(20) not null
); [創建一個表]
describe 表名 [顯示錶的結構]
insert into person values("Jay Chou","周杰倫","12345678"); [向表中插入一條記錄,注:person爲表名]
drop table 要刪除的表名 [刪除表]
delete from 表名 [刪除表中全部記錄]
update 表名 set 屬性名=值 [更新表中數據]
select version() [查詢服務器的版本]
select current_date [查詢服務器當前日期]
select now() [查詢服務器當前時間]
select user() [查看當前用戶]
source 文件路徑(*.sql)[導入sql文件中的命令,進行數據庫的創建等操作]
load data local infile'文件的路徑' into table 表名 [向表中插入純數據格式的數據]
select * from 表名 [查詢表中數據]
select * from 表名 where 屬性=值 [查詢指定數據]
select * from 表名 where 屬性 like '%關鍵字%' [模糊查詢前後包含任意數目字符的含有關鍵字]
select count(*) from 表名 [查詢表中共有多少條記錄]