1.數(shù)據(jù)庫操作
? ? ? ? create database 數(shù)據(jù)名;
? ? ? ? drop database 數(shù)據(jù)庫名雀鹃;????
? ? ? ? show databases;
2.表的操作檬洞;
? ? ? ? create table 表名(
? ? ? ? ? ? ? ? 列名 數(shù)據(jù)類型 屬性 索引 注釋
? ? ? ? ? ? ????constraint 外鍵名 foreign key (外鍵列名稱) references 主表名稱(主表列名稱)
????????????)engine=innerdb 聚霜,charset=utf-8,comment=" "微宝;
? ? ? ? ????drop table 表名1,表名2棺亭;
? ??????????alter table 表名 change 列名 新列名 新數(shù)據(jù)類型;
????????????alter table 表名 modify 列名 新數(shù)據(jù)類型;
? ??????????alter table 表名 add 列名 數(shù)據(jù)類型;
? ??????????alter table 表名 drop 列名;? 刪除列
? ??????????alter table 表名 rename to 新的表名;
? ??????????alter table 表名 rename as 新的表名;
? ??????????desc 表名;? 顯示表結(jié)構(gòu)‘’
? ??????????show tables;
? ? ? ? ? ? use 數(shù)據(jù)庫名;
? ? ? ? ? ? select database()蟋软;
? ? ? ? ? ?3.數(shù)據(jù)庫內(nèi)容的增刪改
? ? ? ? ? ? ? ? ? ??insert into 表名(列名1,列名2,...列名n) values(值1,值2,...值n);
? ??????????????????delete from 表名 [where 條件]侦铜;
? ?????????????????? update 表名 set 列名1 = 值1, 列名2 = 值2,... [where 條件];
? ? ? ? ? ?4.數(shù)據(jù)庫的查詢
? ? ? ? ? ? ? ? ? ? select * from 表名;
? ? ? ? ? ?5.創(chuàng)建索引
? ? ? ? ? ?6.創(chuàng)建外鍵
? ??????????????????add table 從表名 add constraint 外鍵名稱 foreign key (外鍵字段名稱) references 主表名稱(主表列名稱);
? ? ? ? ? ? 7.ALTER TABLE 表名 DROP FOREIGN KEY 外鍵名稱;
????????????????ALTER TABLE 表名 DROP INDEX 索引名稱;
? ? ? ? ? ? ? ? show index from 表名钟鸵;
? ? ? ? ? ? 8.? ? ? set? autocommit=o;
????????????????????start transaction;
? ? ? ? ? ? ? ? ? ? rollback;
? ? ? ? ? ? ? ? ? ? commit;
? ? ? ? ? ? ? ? ? ? set autocommit=1;
作者:醉羽翼
鏈接:http://www.reibang.com/p/a67be0b23609
來源:簡書
簡書著作權(quán)歸作者所有钉稍,任何形式的轉(zhuǎn)載都請聯(lián)系作者獲得授權(quán)并注明出處。