1、顯示所有可用的表:Show tables;
2、顯示所有可用的庫:show databases;
3、顯示table表中的所有列名:describe table;
4、增加列:alter table student(表名) addcolumn sname(列名) varchar(30);
5、修改列:ALTER TABLE student(表名) MODIFYCOLUMN sname(列名) VARCHAR(40);
6、修改列名:alter table student(表名)change column 舊列名 新列名 新的列類型
7、ID自增:
create table test1
(id int auto_increment PRimary key,
name varchar(20) not null,
passWord varchar(20) not null);
8、數(shù)據(jù)庫查詢的時(shí)候拼接:select concat(list1,list2) from table where id=?
9、授權(quán)test用戶擁有testDB數(shù)據(jù)庫的所有權(quán)限(某個(gè)數(shù)據(jù)庫的所有權(quán)限):
grant all privileges on testDB.* to test@localhost identified by '1234';
flush privileges;//刷新系統(tǒng)權(quán)限表
格式:grant 權(quán)限 on 數(shù)據(jù)庫.* to 用戶名@登錄主機(jī) identified by "密碼";
新聞熱點(diǎn)
疑難解答
圖片精選