Home > Database > Mysql Tutorial > body text

创建主键(举例)

WBOY
Release: 2016-06-07 15:57:37
Original
1812 people have browsed it

创建主键(举例) SQL alter table emp_ogg add constraint PK_empno primary key(empno); --创建主键 查询某表有哪些约束 SQL desc user_constraints; Name Null? Type ----------------------------------------- -------- ---------------------------- O

创建主键(举例)

SQL> alter table emp_ogg add constraint PK_empno primary key(empno);

--创建主键

查询某表有哪些约束

SQL> desc user_constraints;

Name Null? Type
----------------------------------------- -------- ----------------------------
OWNER VARCHAR2(30)
CONSTRAINT_NAME NOT NULL VARCHAR2(30)
CONSTRAINT_TYPE VARCHAR2(1)
TABLE_NAME NOT NULL VARCHAR2(30)
SEARCH_CONDITION LONG
R_OWNER VARCHAR2(30)
R_CONSTRAINT_NAME VARCHAR2(30)
DELETE_RULE VARCHAR2(9)
STATUS VARCHAR2(8)
DEFERRABLE VARCHAR2(14)
DEFERRED VARCHAR2(9)
VALIDATED VARCHAR2(13)
GENERATED VARCHAR2(14)
BAD VARCHAR2(3)
RELY VARCHAR2(4)
LAST_CHANGE DATE
INDEX_OWNER VARCHAR2(30)
INDEX_NAME VARCHAR2(30)
INVALID VARCHAR2(7)
VIEW_RELATED VARCHAR2(14)

SQL> select CONSTRAINT_NAME,INDEX_NAME,TABLE_NAME from user_constraints;

--某用户下,查询约束条件

--可以查看是否存在主键

CONSTRAINT_NAME INDEX_NAME TABLE_NAME
------------------------------ ------------------------------ ------------------------------
PK_DEPT PK_DEPT DEPT
PK_EMP PK_EMP EMP
FK_DEPTNO EMP
SYS_C0010809 SYS_C0010809 TCUSTMER
SYS_C0010810 SYS_C0010810 TCUSTORD
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template