In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Primary key constraint SQL > alter table customers add constraint customers_pk primary key (customer_id); Table altered.col constraint_name for a30col constraint_type for a15col table_name for a30col index_name for a30SQL > select constraint_name,constraint_type,table_name,index_name,status from dba_constraints where constraint_type ='P' and owner = 'SOE' CONSTRAINT_NAME CONSTRAINT_TYPE TABLE_NAME INDEX_NAME STATUS -CUSTOMERS_PK P CUSTOMERS CUSTOMERS_PK ENABLEDcol constraint_name for a30col constraint_type for a15col table_name for a30col column_name for a30SQL > select dba_cons_columns.constraint_name Dba_cons_columns.table_name,dba_cons_columns.column_name,dba_cons_columns.positionfrom dba_constraints join dba_cons_columnson (dba_constraints.constraint_name = dba_cons_columns.constraint_name) where constraint_type ='P' and dba_constraints.owner = 'SOE' CONSTRAINT_NAME TABLE_NAME COLUMN_NAME POSITION -- CUSTOMERS_PK CUSTOMERS CUSTOMER_ID 1 disables the constraint SQL > alter table customers disable constraint customers_pk Enable constraints SQL > alter table customers enable constraint customers_pk; delete constraints SQL > alter table customers drop constraint customers_pk; foreign key constraints SQL > alter table orders add constraint orders_customer_id_fk foreign key (customer_id) references customers (customer_id) Table altered.col constraint_name for a30col constraint_type for a20col table_name for a20col r_constraint_name for a30col delete_rule for a15SQL > select constraint_name,constraint_type,table_name,r_constraint_name,delete_rule,status from dba_constraints where constraint_type ='R 'and owner =' SOE' CONSTRAINT_NAME CONSTRAINT_TYPE TABLE_NAME R_CONSTRAINT_NAME DELETE_RULE STATUS -ORDERS_CUSTOMER_ID_FK R ORDERS CUSTOMERS_PK NO ACTION ENABLEDcol child_table_name for a20col father_table_name for a20col child_column_name for a20col father_column_ Name for a20SQL > select dba_cons_columns.constraint_name Dba_cons_columns.table_name as child_table_name,dba_cons_columns.column_name as child_column_name,dba_cons_columns.position,dba_indexes.table_name as father_table_name Dba_ind_columns.column_name as father_column_namefromdba_constraints join dba_cons_columns on (dba_constraints.constraint_name = dba_cons_columns.constraint_name) join dba_indexes on (dba_constraints.r_constraint_name = dba_indexes.index_name) join dba_ind_columns on (dba_indexes.index_name = dba_ind_columns.index_name) where constraint_type ='R 'and dba_constraints.owner =' SOE' CONSTRAINT_NAME CHILD_TABLE_NAME CHILD_COLUMN_NAME POSITION FATHER_TABLE_NAME FATHER_COLUMN_NAME-- -- ORDERS_CUSTOMER_ID_FK ORDERS CUSTOMER_ID1 CUSTOMERS CUSTOMER_ID1, Normal foreign key constraint (if there is a child table referencing the parent table primary key Cannot delete parent table record) SQL > alter table orders add constraint orders_customer_id_fk foreign key (customer_id) references customers (customer_id) 2. Cascading foreign key constraints (parent table records with references can be deleted, and all child table records with references can be deleted at the same time) SQL > alter table orders add constraint orders_customer_id_fk foreign key (customer_id) references customers (customer_id) on delete cascade 3. Empty the foreign key constraint (you can delete the parent table record that has a reference, and automatically set the foreign key field in the child table referencing the parent table primary key to NULL, but this field should allow null values) SQL > alter table orders add constraint orders_customer_id_fk foreign key (customer_id) references customers (customer_id) on delete set null
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.