前言
本文中若无特殊注释,MySQL默认版本为8.0以上。
1.1064错误
1064- You have an error in your SQL syntax;check the manual thatt corresponds to your MySQL server version for the right syntax to use
建表时出现1064错误
原因: 使用字段类型 varchar时没有指明长度
将长度填为255,问题解决
2. 当你知道某个字段,却不知道这个字段在哪个表时,该如何查找
select table_name,column_name from information_schema.columns where column_name like '%字段名%';
例如:你知道字段age,但是你不知道你需要的这个字段age位于哪个表中
就可以这样查询
select table_name,column_name from information_schema.columns where column_name like ‘%age%’;
如果查出来数据太多
可以在table_name前加distinct去重
select distinct table_name,column_name from information_schema.columns where column_name like ‘%age%’;
还是太多
再加where条件
还是太多
加limit限制
3. MySQL用户管理
3.1 显示用户信息
SELECT User, Host FROM mysql.user;
3.2 删除用户
drop user ‘<user.name>’@’<user.address>’
示例:
drop user 'jira'@'localhost'