Mysql知识点集合篇
1.MySql视图保存时表前自动添加数据库名前缀问题
问题根源在于在视图中如果有select * from (select ****),这种嵌套查询,则就会加上数据库名称前缀,解决办法就是把子查询封装成子视图。
2.更新字段为行号:
SET @num = 0; UPDATE ut_project_copy1 SET pp = (@num := @num + 1);
3.查找字段注释
select column_name,column_comment from INFORMATION_SCHEMA.Columns where #table_name='event_base_info' and table_schema='pmes'and column_comment like '%姓名%'
4.设置默认日期和更新日期
`update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
5.生成清空数据表语句
select CONCAT('TRUNCATE TABLE ',table_name,';') from information_schema.tables where TABLE_SCHEMA = 'db1';
6.could not retrieve transation read-only status server(使用了mybatis生成entity):
将pom:
<dependency> <groupId>com.alibaba</groupId> <artifactId>druid</artifactId> <version>1.1.14</version> </dependency>
升级为:
<dependency> <groupId>com.alibaba</groupId> <artifactId>druid</artifactId> <version>1.1.23</version> </dependency>