標籤:
顯示資料庫:show databases;
使用資料庫(串連資料庫 切換資料庫):use+資料庫名稱;
顯示某一資料庫裡的表格:show tables;
建立資料庫:create database+資料庫名稱;
建立表格:
create table student(
id int(4) primary key auto_increment,
name varchar(11) NOT NULL comment "姓名",
number varchar(11) NOT NULL comment "學號"
);
(動作表格內容資料)
查詢某表格裡所有資料:select * from 表格名稱;
// select name,number from 表格名稱;
向某表格裡插入一條資料:insert into 表格名稱 values(屬性值);
// insert into 表格名稱(name,number) values(‘sdf‘,‘sdfgh‘);
刪除某表格裡的某一條記錄:delete from 表名 where 屬性=某一值;
修改某表格裡的某一條記錄:update 表格名稱 set 屬性=某一值 where 屬性=某一值;
(動作表格屬性)
顯示表格結構屬性: desc+表格名稱;
增加某表格的某屬性:alter table 表名 add 屬性名稱 資料類型等;
刪除某表格的某屬性:alter table 表名 drop 屬性名稱;
修改某表格的某屬性:alter table 表名 change 原來的屬性名稱 修改後的屬性名稱 資料類型;
資料類型:範圍按經驗而定
datatime類型是個時間格式
tinyint(4);代表某一個數字;
修改資料庫表格的名稱:rename table 原來的表名 to 現在的表名;
查看修改是否成功: show tables;
刪除資料庫表格:drop table 表名;
刪除資料庫:drop database 資料庫名;
Mysql基本操作