資料庫字段操作

2021-10-11 07:46:41 字數 635 閱讀 8179

1.熟悉oracle 、sql server資料庫欄位的操作

1、 新增乙個新的字段

2、 刪除乙個字段

3、 修改字段型別

1.在表中新增乙個新的字段:

alter table 表名 add 欄位名稱 資料型別

2.修改表中的欄位名稱與字段型別

修改欄位名:alter table 表名 rename column 舊的欄位名 to 新的欄位名

修改資料型別 : alter table 表名 modify (欄位名稱 資料型別)

3.刪除乙個字段(注:刪除前請三思後再執行)

alter table 表名 drop column 欄位名(刪除前檢查字段是否存在)

1.在表中新增乙個新的字段:

alter table (對應的表) add 欄位名稱 資料型別

2.修改表中的欄位名稱與字段型別

修改欄位名:alter table 表名 rename column 舊的欄位名 to 新的欄位名

修改資料型別:alter table 表名 alter column 欄位名 資料型別

3.刪除乙個字段(注:刪除前請三思後再執行)

alter table 表名 drop column 欄位名(刪除前檢查字段是否存在)

mysql資料庫字段操作

建立測試表 create table test id int add支援多列,change drop需要在每列前新增關鍵字,逗號隔開,column 可有可無 新增多列 alter table test add c1 char 1 c2 char 1 alter table test add colu...

資料庫字段

mysql char size 字長字元,0 255位元組 varchar size 變長字元,0 255位元組 date 日期資料,格式為yyyy mm dd hh mm ss datetime 日期資料,比date更確切,包含分秒 int整形資料 double s,p 數字型,可存放實型和整形,...

資料庫查表和字段的操作!

1 查詢sql中的所有表 select table name from 資料庫名稱.information schema.tables where table type base table 執行之後,就可以看到資料庫中所有屬於自己建的表的名稱 2 查詢sql中所有表及列 select dbo.sy...