> 데이터 베이스 > MySQL 튜토리얼 > MySQL 데이터베이스에서 제약 조건 목록을 가져오시겠습니까?

MySQL 데이터베이스에서 제약 조건 목록을 가져오시겠습니까?

WBOY
풀어 주다: 2023-08-30 16:09:03
앞으로
583명이 탐색했습니다.

从 MySQL 数据库获取约束列表?

MySQL 데이터베이스에서 제약 조건 목록을 얻으려면 다음 구문을 사용하세요.

select *from information_schema.table_constraints where constraint_schema = 'yourDatabaseName';
로그인 후 복사

여기서는 "business" 데이터베이스에서 제약 조건을 가져옵니다. 다음은 데이터베이스 "business"의 모든 테이블에 대한 제약 조건을 나열하는 쿼리입니다. -

mysql> select *
   −> from information_schema.table_constraints
   −> where constraint_schema = 'business';
로그인 후 복사

다음은 모든 제약 조건을 보여주는 출력입니다. -

+--------------------+-------------------+--------------------------+--------------+------------------------------+-----------------+
| CONSTRAINT_CATALOG | CONSTRAINT_SCHEMA | CONSTRAINT_NAME          | TABLE_SCHEMA | TABLE_NAME                   | CONSTRAINT_TYPE |
+--------------------+-------------------+--------------------------+--------------+------------------------------+-----------------+
| def                | business          | PRIMARY                  | business     | primarytable                 | PRIMARY KEY     |
| def                | business          | PRIMARY                  | business     | primarytable1                | PRIMARY KEY     |
| def                | business          | PRIMARY                  | business     | autoincrementtable           | PRIMARY KEY     |
| def                | business          | PRIMARY                  | business     | demoauto                     | PRIMARY KEY     |
| def                | business          | PRIMARY                  | business     | autoincrement                | PRIMARY KEY     |
| def                | business          | PRIMARY                  | business     | primarytabledemo             | PRIMARY KEY     |
| def                | business          | PRIMARY                  | business     | sequencedemo                 | PRIMARY KEY     |
| def                | business          | PRIMARY                  | business     | updtable                     | PRIMARY KEY     |
| def                | business          | PRIMARY                  | business     | transcationdemo              | PRIMARY KEY     |
| def                | business          | PRIMARY                  | business     | triggedemo                   | PRIMARY KEY     |
| def                | business          | PRIMARY                  | business     | usernameandpassworddemo      | PRIMARY KEY     |
| def                | business          | UserId                   | business     | usernameandpassworddemo      | UNIQUE          |
| def                | business          | PRIMARY                  | business     | tblp                         | PRIMARY KEY     |
| def                | business          | name                     | business     | uniquedemo                   | UNIQUE          |
| def                | business          | name                     | business     | uniqueconstdemo              | UNIQUE          |
| def                | business          | PRIMARY                  | business     | keydemo                      | PRIMARY KEY     |
| def                | business          | PRIMARY                  | business     | nextiddemo                   | PRIMARY KEY     |
| def                | business          | PRIMARY                  | business     | tablepri                     | PRIMARY KEY     |
| def                | business          | ConstFK                  | business     | tabledemo2                   | UNIQUE          |
| def                | business          | ConstFK                  | business     | tabledemo3                   | UNIQUE          |
| def                | business          | PRIMARY                  | business     | college                      | PRIMARY KEY     |
| def                | business          | id                       | business     | uniquedemo1                  | UNIQUE          |
| def                | business          | id                       | business     | uniqueautoid                 | UNIQUE          |
| def                | business          | PRIMARY                  | business     | schemadatabasemethoddemo     | PRIMARY KEY     |
| def                | business          | PRIMARY                  | business     | employeeinformation          | PRIMARY KEY     |
| def                | business          | name                     | business     | addingunique                 | UNIQUE          |
| def                | business          | PRIMARY                  | business     | parentdemo                   | PRIMARY KEY     |
| def                | business          | PRIMARY                  | business     | lastinsertrecordiddemo       | PRIMARY KEY     |
| def                | business          | PRIMARY                  | business     | demoindex                    | PRIMARY KEY     |
| def                | business          | PRIMARY                  | business     | compositeprimarykey          | PRIMARY KEY     |
| def                | business          | PRIMARY                  | business     | addingautoincrement          | PRIMARY KEY     |   
| def                | business          | Id                       | business     | uniqueconstrainttable        | UNIQUE          |
| def                | business          | PRIMARY                  | business     | mergedemo1                   | PRIMARY KEY     |
| def                | business          | PRIMARY                  | business     | mergedemo2                   | PRIMARY KEY     |
| def                | business          | PRIMARY                  | business     | foreigntable1                | PRIMARY KEY     |
| def                | business          | PRIMARY                  | business     | twoprimarykeytabledemo       | PRIMARY KEY     |
| def                | business          | PRIMARY                  | business     | showconstraintsdemo          | PRIMARY KEY     |
| def                | business          | BookAuthor               | business     | showconstraintsdemo          | UNIQUE          |
| def                | business          | PRIMARY                  | business     | autoincrementtozero          | PRIMARY KEY     |
| def                | business          | PRIMARY                  | business     | altertabletoaddautoincrement | PRIMARY KEY     |
| def                | business          | PRIMARY                  | business     | addingprimarykeydemo         | PRIMARY KEY     |
| def                | business          | PRIMARY                  | business     | resetprimarykey              | PRIMARY KEY     |
| def                | business          | constFKPK                | business     | foreigntable                 | FOREIGN KEY     |
| def                | business          | FKConst                  | business     | foreigntabledemo             | FOREIGN KEY     |
| def                | business          | ConstFK                  | business     | tblf                         | FOREIGN KEY     |
| def                | business          | StudCollegeConst         | business     | studentenrollment            | FOREIGN KEY     |
| def                | business          | ConstChild               | business     | childdemo                    | FOREIGN KEY     |
| def                | business          | primarytable1demo_ibfk_1 | business     | primarytable1demo            | FOREIGN KEY     |
+--------------------+-------------------+--------------------------+--------------+------------------------------+-----------------+
48 rows in set, 2 warnings (0.24 sec)
로그인 후 복사

위 내용은 MySQL 데이터베이스에서 제약 조건 목록을 가져오시겠습니까?의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

원천:tutorialspoint.com
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿