資料庫 insert 增加列

2021-09-26 01:20:54 字數 1209 閱讀 4022

一些出現的問題

1.insert 增加列

增加乙個列:

alter table 表名 add(列名 資料型別);

如:alter table emp add(weight number(38,0));

修改乙個列的資料型別(一般限於修改長度,修改為乙個不同型別時有諸多限制):

alter table 表名 modify(列名 資料型別);

如:alter table emp modify(weight number(3,0) not null);

給列改名:

alter table 表名 rename column 當前列名 to 新列名;

如:alter table emp rename column weight to weight_new;

刪除乙個列:

alter table 表名 drop column 列名;

如:alter table emp drop column weight_new;

將乙個表改名:

alter table 當前表名 rename to 新錶名;

如:alter table bouns rename to bonus_new

需要修改結構的,就用到alter語句,方法如下:

alter table語句用於修改已經存在的表的設計。

alter table (表名) add (列名 資料型別);

alter table (表名) modify (列名 資料型別);

alter table (表名) rename column (當前列名) to (新列名); /不需要括號

alter table (表名) drop column (列名);

alter table (當前表名) rename to (新錶名);

如:alter table employ add (weight number(38,0)) ;

alter table employ modify (weight number(13,2)) ;

alter table emp rename cloumn weight to weight_new ;

alter table emp drop column weight_new ;

alter table bouns rename to bonus_new;

資料庫增加新列

2017年02月14日 11 24 11 public class copyofdatabasehelper extends sqliteopenhelper return db helper public copyofdatabasehelper context context 資料庫建立時執行 ...

資料庫的增 刪 改 查 增加列 刪除列

varchar n n為數字,表示n位數的字元。增 create datebase xuesheng 建立乙個xuesheng的資料庫,注意要有go go create table xueshengxinxi code int,編號為int name varchar 20 名字為varchar sc...

MSSQL資料庫資料匯出insert

create proc spgeninsertsqlhan tablename varchar 256 as begin declare sql varchar max declare sqlvalues varchar max set sql set sqlvalues values select...