修改表:
添加欄位:alter table yyh_yp_managerrob add catid smallint(5)
, add typeid smallint(5)
, add areaid smallint(5)
, add title char(150)
, add style char(5)
, add thumb char(100)
, add keywords char(40)
, add description char(255)
, add posids tinyint(1)
, add url char(100)
, add listorder tinyint(3)
, add status tinyint(2)
, add userid mediumint(8)
, add username char(20)
, add inputtime int(10)
, add updatetime int(10)
, add searchid mediumint(8)
, add islink tinyint(1)
, add prefix char(20);
複製表結構:create table newtable (select * from oldtable)
還原資料庫:
先刪除掉原有的資料庫:drop database 資料庫名稱
然後建立資料庫:creat database 資料庫名稱
然後:use 資料庫名稱
然後:source .sql檔案的路徑
補充:
MySQL添加欄位的方法並不複雜,下面將為您詳細介紹MySQL添加欄位和修改欄位等操作的實現方法,希望對您學習MySQL添加欄位方面會有所協助。
1.登入資料庫
>mysql -u root -p 資料庫名稱
2.查詢所有資料表
>show tables;
3.查詢表的欄位資訊
>desc 表名稱;
4.1添加表欄位
alter table table1 add transactor varchar(10) not Null;
alter table table1 add id int unsigned not Null auto_increment primary key
4.2.修改某個表的欄位類型及指定為空白或非空
>alter table 表名稱 change 欄位名稱 欄位名稱 欄位類型 [是否允許非空];
>alter table 表名稱 modify 欄位名稱 欄位類型 [是否允許非空];
>alter table 表名稱 modify 欄位名稱 欄位類型 [是否允許非空];
4.3.修改某個表的欄位名稱及指定為空白或非空
>alter table 表名稱 change 欄位原名稱 欄位新名稱 欄位類型 [是否允許非空
4.4如果要刪除某一欄位,可用命令:ALTER TABLE mytable DROP 欄位 名;