show databases; //展示有哪些數據庫 use test; //use +數據庫名,進入數據庫 show tables; //顯示庫里的表 show tables from mysql; //show tables from +庫名,查看指定庫內的表,查看時并不會離開當前庫,或者用前兩種方式use進入后show,
select database(); //查看當前所在哪個庫 創建表:
create table hellowrold( //create table 后指定表名 id int, //指定列名和類型還要指定其他列名時用,號分隔 name varchar(20)); //varchar(20); 長度為20的字符串類型 desc hellowrold; //desc +表名顯示表的框架等詳細數據 select (星號) from hellowrold; //select from +表名,查看表內數據
insert into hello(id,name) values(1,"me"); //插入數據到表頭,insert into +表名(列名,列名) values(賦值,賦值);
update hello set address="she" where id =1; //修改id=1對應的address的列的名字為 she, updata +表名 +set+ 列名="賦值" +where+另一個列名 =另一個列名對應的值;
delete from hello where id =1; //刪除hello表中,id列值為1所在的行,delete from+ 表頭+where +列名=值;