2019独角兽企业重金招聘Python工程师标准>>>
-
UPDATE user_0 SET phone=REPLACE(phone,'13800','14400') //把phone中的13800替换为14400
-
select id,birth from user_view WHERE birth LIKE CONCAT('%',SUBSTR(DATE_FORMAT(CURRENT_DATE(),'%Y-%c-%e'),5,9),'%')//当天生日的用户
3.SELECT * FROM login_log GROUP BY userId HAVING COUNT(1) =1 //查询表中userId不重复的记录
mysql清空数据库数据
truncate
myql恢复清空的数据库数据
mysql删除数据库
drop database databaseName;
mysql恢复删除的数据库
mysql删除表数据
delete from tableName;
mysql恢复表数据
mysql删除表
drop table tableName;
mysql恢复表
------------------------------------------------------------------------------
SHOW PROCESSLIST#显示哪些线程正在运行
------------------------------------------------------------------------------
指令:
1.本地终端远程登录mysql服务器:
第一步:授权法:GRANT ALL PRIVILEGES ON *.* TO ‘myuser’@'%’ IDENTIFIED BY ‘mypassword’ WITH GRANT OPTION;
例:grant all privileges on *.* to 'root'@'%' identified by 'mypassword'with grant option;
第二步:
mysql -u userName -ppassword -h ipAddress -P 3306 -D dbName
注: (1)服务器端口标志-P一定要大些以区别于用户-p,如果直接连接数据库标志-D也要大写;
(2)如果要直接输入密码-p后面不能留有空格如-pmypassword;
(3)命令结束段没有';'分号。
2.查看表结构:show columns from tableName;
desc tableName;
3.删除表:drop table tableName;
4.insert语句的三种形式:
a.改变列顺序插入,同时数值顺序也要一直调整.
b.省略列名,列名列表可省略,但数据值必须全部填入,且必须与当初建表时完全相同.
c.省略部分列,同时只能填入部分数据.
5.当某条记录存在时更新记录,不存在则插入记录:replace into imid_userId values(#{imid},#{userId})
SQL语句:
1.查询表数量:
SELECT COUNT(TABLE_NAME)FROM information_schema.TABLES WHERE TABLE_SCHEMA='yourdbName';
2.创建视图:
CREATE VIEW user_view_all AS
SELECT * FROM user_0 UNION
SELECT * FROM user_1 UNION
SELECT * FROM user_2 UNION
SELECT * FROM user_3 UNION
SELECT * FROM user_4 UNION
SELECT * FROM user_5 UNION
SELECT * FROM user_6 UNION
SELECT * FROM user_7
;
==========================================================
mysql8客户端连接的坑:
解决方法:
ALTER USER '用户名'@'%' IDENTIFIED WITH mysql_native_password BY '用户密码';