下面是幾種不同資料庫的公升級指令碼比較,實際上是對不同資料庫版本的alter命令用法的比較
約定:內的內容可有可無
1,修改字段型別[關鍵字:modify&alter]
mysql:
alter table 表名 modify [column] 欄位名 字段型別定義;
sqlserver:
alter table 表名 alter column 欄位名 字段型別定義;
[這裡在修改約束的時候需要用到專門的關鍵字constraint]
oracle:
alter table 表名 modify ( 欄位名 字段型別定義);
[oracle,修改型別時所改字段的資料必須為空:]
2,增加和刪除字段
增加字段
alter table 表名 add 欄位名 字段型別定義;
刪除字段
mysql:
alter table 表名 drop[column] 欄位名
sqlserver:
alter table 表名 drop column 欄位名
3,修改列名
mysql:
可以用change同時修改列名和列型別,如:
alter table table change column newcolumn bit not null
這裡column和newcolumn可以相同,
也就是說,change可以取代modify了,可以用來單純修改列型別或者列名
sqlserver:
暫時只能呼叫儲存過程
exec sp_rename table.column','newcolumn','column'
oracle:
在817版本以上支援rename了,沒有具體測試過,9i以上版本比較保險
alter table table rename column column to newcolumn;
oracle 庫中新增列:
alter table cdata_bbb_144_picinfo add istop varchar2(255);
JDBC連線各種資料庫方法
1 oracle8 8i 9i資料庫 thin模式 class.forname oracle.jdbc.driver.oracledriver newinstance string url jdbc oracle thin localhost 1521 orcl orcl為資料庫的sid strin...
JDBC連線各種資料庫方法
1 oracle8 8i 9i資料庫 thin模式 class.forname oracle.jdbc.driver.oracledriver newinstance string url jdbc oracle thin localhost 1521 orcl orcl為資料庫的sid strin...
JDBC連線各種資料庫方法
jdbc連線各種資料庫的方法如下 1 oracle8 8i 9i資料庫 thin模式 class.forname oracle.jdbc.driver.oracledriver newinstance string url jdbc oracle thin localhost 1521 orcl o...