本文共 1621 字,大约阅读时间需要 5 分钟。
1.复制表结构和数据,但是不复制索引和外键:
- create table a select * from b;
- insert into a select * from b;
- --新建一个临时表
- create table tmp as select * from youtable group by name ;
- --删除原来的表
- drop table youtable ;
- --重命名表
- alter table tmp rename youtable;
- --新建一个临时表
- create table tmp like youtable;
- --取出不重复的数据
- insert into select * from youtable group by name;
- --清空原来的表
- truncate youtable;
- --插入原来的表
- insert into youtable select * from tmp;
- --重命名表
- drop table tmp;
- SELECT FROM_UNIXTIME( 1249488000,'%Y-%m-%d %H:%i:%s') ;
- SELECT DATE_FORMAT('1997-10-04 22:23:00', '%Y-%m-%d %H:%i:%s');
- SELECT UNIX_TIMESTAMP('2009-08-06') ;
- --查看日志
- show binary logs;
- show master logs;
- --清除日志
- PURGE MASTER LOGS TO 'mysql-bin.000035';
- --手动删除10天前的mysql binlog日志
- PURGE MASTER LOGS BEFORE DATE_SUB(CURRENT_DATE, INTERVAL 10 DAY);
- SET sql_mode='ANSI_QUOTES';
- create table "a-b" (a int);
- insert into node (name) select 'a' where no exists(select id from node where id=2 and name='a')
- select replace(uuid(), '-', '');
15.添加一个远程用户,名为username密码为password
- GRANT ALL PRIVILEGES ON *.* TO username@"%" IDENTIFIED BY 'password' WITH GRANT OPTION;
- LOAD DATA INFILE '/tmp/result100.txt' INTO TABLE analy_ip_file2 FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n';
- alter table userconfig add id int(4) auto_increment primary key;
- show variables like '%max%';
转载地址:http://ffxxa.baihongyu.com/