停止 恢復約束 sql

2022-03-29 02:32:23 字數 360 閱讀 5275

--可以把外來鍵約束暫時停止了,再刪除資料,刪除後再恢復外來鍵約束

具體語句是,sql2000中用法

alter table 表的名字

nochek constraint 外來鍵約束名字

truncate table 表的名字

alter table 表的名字

check constraint 外來鍵約束名字 --

-- 停止c_mxbcardinfo所有約束

alter table c_mxbcardinfo nocheck constraint all

-- 恢復所有約束

alter table c_mxbcardinfo check constraint all

sql主鍵約束

資料字段屬性 unsigned 無符號的,宣告該資料不允許為負數 zerofill 0填充的,不足位數用0來填充 如 int 3 5 則005 auto increment 自動增長的,通常用於設定主鍵,且為整數型別,可定義起始值和步長 null not null 空 和 非空 default 預設...

SQL 新增約束

sql 約束用於規定表中的資料規則。如果存在違反約束的資料行為,行為會被約束終止。約束可以在建立表時規定 通過 create table 語句 或者在表建立之後規定 通過 alter table 語句 建立表的時候新增約束 create table table name column name1 d...

SQL約束(對比)

約束主要包括 not null unique primary key foreign key check default 1 not null 用於控制欄位的內容一定不能為空 null 用法 create table mytable id varchar 32 not null,name varch...