Humble Trader

Wednesday, September 06, 2006

Constraint Create Script Template

-- ------------------------------------------------------------------------- --
-- --
-- Title: [table_name]_c.sql --
-- Author: Steve Roach --
-- Date: DD-MON-YYYY --
-- Version: 01.00 --
-- --
-- Description: Create constraints for table [TABLE_NAME]. --
-- --
-- History: --
-- --
-- Date Ver Author Description --
-- --------- ----- ------ -------------------------------------------------- --
-- DD-MON-YY 01.00 SRR First release --
-- --
-- ------------------------------------------------------------------------- --

ALTER TABLE [table_name] DROP CONSTRAINT [table_name]_pk
/

ALTER TABLE [table_name] DROP CONSTRAINT [table_name]_f1
/

ALTER TABLE [table_name] ADD CONSTRAINT [table_name]_pk PRIMARY KEY
(
[column_1]
,[column_2]
,...
) USING INDEX [table_name]_pk
/

ALTER TABLE [table_name] ADD CONSTRAINT [table_name]_f1
FOREIGN KEY
(
[column_1]
,[column_2
,...
) REFERENCES [other_table_name]([column_3]
,column_4])
/

0 Comments:

Post a Comment

<< Home