主键索引:
ALTER TABLE DES_ADSL ADD CONSTRAINT PK_DES_ADSL PRIMARY KEY (SERVICEID, SERVICEIDSEQ);
ALTER TABLE DES_ADSL ADD DROP?PRIMARY KEY;
CREATE INDEX IDX_ADDR_SEGM_FROM ON ADDR_SEGM (ADDR_FROM ASC);
CREATE INDEX IDX_ADDR_SEGM_ID
? ON ADDR_SEGM (SEGM_ID ASC);
CREATE INDEX IDX_ADDR_SEGM_ID_2
? ON ADDR_SEGM (PARENT_SEGM_ID ASC);
CREATE INDEX IDX_ADDR_SEGM_REGIONID
? ON ADDR_SEGM (REGION_ID ASC);
CREATE INDEX IDX_ADDR_SEGM_RELA_ID
? ON ADDR_SEGM (RELA_ID ASC);
CREATE INDEX IDX_ADDR_SEGM_SEGM_NAME
? ON ADDR_SEGM (SEGM_NAME ASC);
CREATE INDEX IDX_ADDR_SEGM_STANDNAME
? ON ADDR_SEGM (STAND_NAME ASC);
外键:
SELECT
CONSTRAINT_NAME,
TABLE_NAME,
COLUMN_NAME,
REFERENCED_TABLE_NAME,
REFERENCED_COLUMN_NAME
FROM
INFORMATION_SCHEMA.KEY_COLUMN_USAGE
WHERE
REFERENCED_TABLE_SCHEMA = 'resdb';
+--------------------------------+--------------------------+----------------+-----------------------+------------------------+
| CONSTRAINT_NAME | TABLE_NAME | COLUMN_NAME | REFERENCED_TABLE_NAME | REFERENCED_COLUMN_NAME |
+--------------------------------+--------------------------+----------------+-----------------------+------------------------+
| FK_ODNID | AN_ODN_PICTURE | ODNID | AN_ODN | ID |
| FK_DES_SERVICEORDER_SERVICE1 | DES_SERVICEORDER_SERVICE | SERVICEORDERID | DES_SERVICEORDER | SERVICEORDERID |
| FK_G_ROOM_F_REFERENCE_G_EQUIP_ | G_ROOM_FIXING | EQUIP_TYPE | G_EQUIP_TYPE | ID |
| FK_TP_FACTO_REFERENCE_FACTORY | TP_FACTORY_CARD_TYPE | FACTORY_ID | FACTORY | ID |
+--------------------------------+--------------------------+----------------+-----------------------+------------------------+
4 rows in set (0.00 sec)
删除外键:
alter table AN_ODN_PICTURE drop foreign key FK_ODNID;
alter table DES_SERVICEORDER_SERVICE drop foreign key FK_DES_SERVICEORDER_SERVICE1;
alter table G_ROOM_FIXING drop foreign key FK_G_ROOM_F_REFERENCE_G_EQUIP_;
alter table TP_FACTORY_CARD_TYPE drop foreign key FK_TP_FACTO_REFERENCE_FACTORY;