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、數據庫查詢的時候拼接:select concat(list1,list2) from table where id=?
9、授權test用戶擁有testDB數據庫的所有權限(某個數據庫的所有權限):
grant all privileges on testDB.* to test@localhost identified by '1234';
flush privileges;//刷新系統權限表
格式:grant 權限 on 數據庫.* to 用戶名@登錄主機 identified by "密碼";
新聞熱點
疑難解答