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 user@192.168.229.130 identified by "xiaobai";
或者
grant replication slave on *.* user@192.168.229.130 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中关于表操作的实用技巧,包括修改表字段的默认值、判断字段是否为NULL、设置用户权限等,并提供了如何更新表数据的具体方法。
3万+

被折叠的 条评论
为什么被折叠?



