mysql 笔记

1. alter table tablename alter column drop default; (若本身存在默认值,则先删除)

     alter table tablename alter column set default 't5';(若本身不存在则可以直接设定)

2. 判断字段为NULL,用 is NULL.

 

3.

mysql>grant all on db.* to 'test'@'localhost' identified by 'test';
上例运行后的效果是,test用户只能通过‘test’密码从本机访问db数据库

mysql>grant all on db.* to 'test'@'%' identified by 'test';
上例运行后的效果是,test用户可通过‘test’密码从任意计算机上访问db数据库。‘%’代表任意字符,‘_’代表一个任意字符。主机名部份还可以是IP地址。

 

全部权限:

用户授权:
grant all on *.* to [email protected] identified by "xiaobai";
或者
grant replication slave on *.* [email protected] identified by "xiaobai"

 

4.

查看表是否存在:

show tables like 表名.
 

5.

在sql server中,我们可是使用以下update语句对表进行更新:

update a set a.xx= (select yy from b) where a.id = b.id ;

但是在mysql中,不能直接使用set select的结果,必须使用inner join:

update a inner join (select yy from b) c on a.id =b.id  set a.xx = c.yy

你可能感兴趣的:(mysql 笔记)