新增 檢視 刪除外來鍵

2021-06-06 20:48:45 字數 300 閱讀 5006

新增外來鍵

alter table sitecodes drop foreign key fk_sitecodes

設定外來鍵

alter table 需要建立外來鍵的表 add constraint 外鍵名字 foreign key  references 外來鍵表(外來鍵字段) ,

alter table sitecodes add constraint fk_sitecodes foreign key (locationid) references

location(locationid)  

刪除外來鍵約束

主表 create table test1 id int primary key not null,value int insert test1 select 1,2 go 從表 create table test2 id int references test1 id value int go 第...

MySQL刪除外來鍵

1 刪除表中的外來鍵 語法 alter table tablename drop foreign key foreignkeyname 比如我要刪除account表中user id所引用的外來鍵 先輸入show create table account 檢視建表語言 返回如下資訊 可知外來鍵名為 f...

新增檢視使用者

關於查詢使用者名稱 select from mysql.user g mysql新增使用者方法 建立資料庫gamesp create database gamesp 新增使用者 grant all on 資料庫名.to 使用者名稱 localhost identified by 密碼 grant a...