mysql 檢視表中所有約束

2022-07-10 15:33:10 字數 795 閱讀 1400

一、檢視所有資料庫中所有約束

select * from information_schema.key_column_usage;

系統字典中所有列:

constraint_catalog |

constraint_schema |

constraint_name|

table_catalog |

table_schema | table_name  |

column_name  |

ordinal_position |

position_in_unique_constraint |

referenced_table_schema |

referenced_table_name |

referenced_column_name |

二、檢視指定表中所有約束

第一種:

select constraint_catalog,

constraint_schema,#想要哪個字段可以根據自己需求選擇

constraint_name,

table_schema,

table_name,

constraint_type

from

information_schema.table_constraints

where

table_name='t_org'

我這個表du名zhi是t_org

第二種:

show create table 你的表名;

這個適合命dao令行。

MySQL檢視表中的約束

在 mysql 中可以使用 show create table 語句來檢視表中的約束。檢視資料表中的約束語法格式如下 show create table 資料表名 例項 建立資料表 tb emp8 並指定 id 為主鍵約束,name 為唯一約束,deptid 為非空約束和外來鍵約束,然後檢視表中的約...

mysql檢視表結構索引 mysql檢視表結構命令

mysql檢視表結構命令,如下 desc 表名 show columns from 表名 describe 表名 show create table 表名 use information schema select from columns where table name 表名 順便記下 show...

禁止及啟用表的所有約束

1 單錶語句 禁止表的單個約束 alter table table name nocheck constraint constraint name 禁止表的所有約束 alter table table name nocheck constraint all 啟用表的單個約束 alter table ...