1、數(shù)據(jù)庫(kù)操作:
show databases; 查詢所有數(shù)據(jù)庫(kù)
create database 數(shù)據(jù)庫(kù)名;創(chuàng)建數(shù)據(jù)庫(kù)
use 數(shù)據(jù)庫(kù)名;進(jìn)入數(shù)據(jù)庫(kù)
select database();查詢目前在那個(gè)數(shù)據(jù)庫(kù)下
drop database 數(shù)據(jù)庫(kù)名;刪除該數(shù)據(jù)庫(kù)下的視圖
2、表操作
show tables;顯示所有表
create table 表名(字段 字段類型,字段 字段類型);創(chuàng)建表?字段
desc 表名;進(jìn)入該表
show create table 表名;創(chuàng)建表
alter table 表名add/modify/change/drop/rename to …;修改表名
drop table 表名;刪除表
3、數(shù)據(jù)的添加、修改、刪除操作
添加數(shù)據(jù)
insert into 表名(字段1,字段2,…)values(值1,值2,…);
修改數(shù)據(jù)
update 表名 set 字段1=值1,字段2=值2【where 條件】;
刪除數(shù)據(jù)
delete from 表名【where 條件】;沒(méi)加條件就是刪除整張表的數(shù)據(jù)