常用SQL

作者: JiangCheng97 | 来源:发表于2019-07-08 16:47 被阅读0次
  • 删除前七天的数据
DELETE FROM table WHERE (TO_DAYS(NOW()) - TO_DAYS(CREATE_TIME)) >= 7;
  • 导出数据
select * from  testTable WHERE id > 2000 into outfile '/tmp/testTable .csv' fields terminated by ',' optionally enclosed by '"' escaped by '"' lines terminated by '\r\n';
  • 导入数据
LOAD DATA INFILE '/tmp/testTable .csv' INTO TABLE testTable fields terminated by ',' optionally enclosed by '"' escaped by '"' lines terminated by '\r\n';
  • 备份表
mysqldump -uroot  -ppassword -S /var/lib/mysql/mysql.sock --default-character-set=utf8 -R  --triggers  --events --opt --set-gtid-purged=off --hex-blob --single-transaction ordercenter testTable--where 'id>10000'> /tmp/testTable.sql

相关文章

网友评论

      本文标题:常用SQL

      本文链接:https://www.haomeiwen.com/subject/fbrahctx.html