SELECT CONCAT("mysqldump -uroot -poldboy123 ",TABLE_SCHEMA," ",TABLE_NAME," >/tmp/",TABLE_SCHEMA,"/",TABLE_SCHEMA,"_",TABLE_NAME,".sql") FROM information_schema.`TABLES` WHERE TABLE_SCHEMA=‘world‘ INTO OUTFILE ‘/tmp/bf.sh‘
[mysqld]
secure-file-priv=/tmp
-- 加入上面语句重启mysql
创建表:
create table test(id int);
create table t1(idcard int ,name char(30),sex char(4));
修改表定义:
修改表名:
rename table t1 to test1;
alter table test1 rename to people;
修改表结构:
alter table people add addr char(40) NOT NULL;
指定添加年龄列到name列后面的位置,示例如下:
alter table people add age int(4) after name;
通过下面的命令在第一列添加qq字段。
alter table test add telnum int first;
同时添加多个列定义:
alter table people add id int first ,add sex char(4) after name ;
删除表结构:
alter table people drop sex;
修改表定义
alter table people modify name char(20);
修改列名:
alter table people change name people_name char(30) ;