工作中常用SQL語句

2021-10-07 23:10:35 字數 1325 閱讀 3255

新增列:

執行下列命令,列會預設新增到表字段末尾

alter table 表名 add column 列名 varchar(30);
如果想指定字段位置,可以使用mysql提供的first(設定為第一列)和after(設定位於某個字段之後)

first和 after關鍵字只用於 add 子句

刪除列:

alter table 表名 drop column 列名;
修改列名:

alter table 表名 change 列名 新列名 varchar(30);
修改列屬性:

alter table 表名 modify 列名 varchar(22);
修改字段預設值:

alter table 表名 alter 欄位名 set default 1000;
修改資料表型別:

可以使用alter 命令及 type子句來完成。以下命令將表students 的型別修改為 myisam

alter table student engine= myisam;
檢視表中字段的預設值:

show columns from 表名
檢視表:

desc 表名;
1、新增字段

alter table 表名 add 欄位名 type not null default 0

2、修改欄位名

alter table 表名 rename column a to b

3、修改字段型別

alter table 表名 modify column unitprice decimal(18, 4) not null 

4、修改字段預設值

alter table 表名 drop constraint 約束名字   ------說明:刪除表的字段的原有約束

alter table 表名 add constraint 約束名字 default 預設值 for 欄位名稱 -------說明:新增乙個表的字段的約束並指定預設值

5、刪除字段

alter table 表名 drop column 欄位名;

linux 工作中常用

一,help 獲取shell內建命令幫助資訊 示例 help cd 二,常用快捷按鍵 1 ctrl c 停止程序 如 tail f 後,退出按 ctrl c 返回到命令列。2 ctrl l 清屏 3 ctrl q 退出 4 tab 自動補全 在linux 和 window的cmd命令列中可用。5 上...

工作中常用的命令

1.unzip zip archive tar cf new.tar path tar xvf file.tar 2.transfer files scp username ip path path first path 傳輸檔案路徑 second path 儲存的路徑 安裝ssh伺服器 apt g...

工作中常用的工具

寫 evc,vs2005,visual assist 讀 source insight 檔案比較 ultra compare 編輯器 ultra edit 設計圖 viso 串列埠除錯 dnw,串列埠除錯助手 linux unubtu9.0,armlinux 交叉編譯 cygwin,cegcc 虛擬...