1. 程式人生 > >一個備份語句和常用的修改表的語句

一個備份語句和常用的修改表的語句

ren 常用 secure pan idc mysql col /tmp uri

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) ;

一個備份語句和常用的修改表的語句