sql更改表操作

2021-10-23 06:20:59 字數 792 閱讀 7074

rename table 原名 to 新名字;

alter table 原名 rename 新名;

alter table 原名 rename to 新名;

drop table 表名字;

drop database test_01;

alter table 表名字 add column 列名字 資料型別 約束;

或:alter table 表名字 add 列名字 資料型別 約束;

alter table employee add weight int(4) default 120 after age;

alter table employee add test int(10) default 11 first;

alter table 表名字 drop column 列名字;

或: alter table 表名字 drop 列名字;

alter table employee drop test;

alter table 表名字 change 原列名 新列名 資料型別 約束;

alter table 表名字 modify 列名字 新資料型別;

更改表中某個值

update 表名字 set 列1=值1,列2=值2 where 條件;

update employee set age=21,salary=3000 where name=『tom』;

刪除一行記錄

delete from 表名字 where 條件;

delete from employee where name=『tom』;

SQL 的常用更改表約束

sql 的常用更改表約束 一 修改字段預設值 alter table 表名 drop constraint 約束名字 說明 刪除表的字段的原有約束 alter table 表名 add constraint 約束名字 default 預設值 for 欄位名稱 說明 新增乙個表的字段的約束並指定預設值...

SQL基礎 建立 更改和刪除表

建立表 約束使用default確定預設值 使用primary key指定主鍵 使用foreign key指定外來鍵 使用unique確保值唯一 使用check建立檢查約束 使用create temporary table建立臨時表 使用create table as利用已存在表建立新錶 使用alte...

mysql更改表資訊 MYSQL修改表操作

1.登入資料庫 mysql h localhost u root p 資料庫名稱 2.查詢所有的資料庫 show databases 3.選擇資料庫 use 資料庫名 4.查詢所有資料表 show tables 5.查詢表的字段資訊 desc 表名稱 6.1.修改某個表的字段型別及指定為空或非空 a...