Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Can this way solve the column renaming problem?

Can this way solve the column renaming problem?

From: <wy3141_at_my-deja.com>
Date: Tue, 14 Sep 1999 12:11:32 GMT
Message-ID: <7rle1c$dra$1@nnrp1.deja.com>

I had saw the same problem solved by sql server 7.0. I first create two table and add some constraints on it. And I delete one column and it generate the scripts below.

/*************this is prepare work*****************/
Create Table Table1(
f1 Char(10),
f2 char(10),
f3 Datetime default GetDate(),
Primary key(f1)
)

Create Table Table2(
t1 Char(10),
Table1_f1 char(10) references Table1(f1), f3 Datetime default GetDate(),
Primary key(t1)
)

Grant Select on Table1 to role1

Create Trigger Table1_IUD On Table1
for Insert,Update,Delete
As
Print 'Test Trigger';
Return

Insert into Table1 values('1','a','1999-9-14')

/************end of prepare work**********************/

After I delete a column f3 in the table1 in the enterprise manager. It creates scripts below.

/* 1999Äê9ÔÂ14ÈÕ 19:29:47 User: sa Server: SCSNET Database: pubs Application: SQL Server Enterprise Manager */ BEGIN TRANSACTION SET QUOTED_IDENTIFIER ON
GO
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE GO
COMMIT
BEGIN TRANSACTION
ALTER TABLE dbo.Table1
DROP CONSTRAINT DF__Table1__f3__5CA1C101 GO
CREATE TABLE dbo.Tmp_Table1
(

  f1 char(10) NOT NULL,
f2 char(10) NULL
) ON [PRIMARY]
GO
IF EXISTS(SELECT * FROM dbo.Table1)
  EXEC('INSERT INTO dbo.Tmp_Table1(f1, f2)   SELECT f1, f2 FROM dbo.Table1 TABLOCKX') GO
ALTER TABLE dbo.Table2
DROP CONSTRAINT FK__Table2__Table1_f__5F7E2DAC GO
DROP TABLE dbo.Table1
GO
EXECUTE sp_rename 'dbo.Tmp_Table1', 'Table1' GO
ALTER TABLE dbo.Table1 ADD CONSTRAINT
PK__Table1__5BAD9CC8 PRIMARY KEY CLUSTERED
(

f1
) ON [PRIMARY]
GO
Create Trigger Table1_IUD On dbo.Table1 for Insert,Update,Delete
As
Print 'Test Trigger';
Return
GO
GRANT SELECT ON dbo.Table1 TO Role1 AS dbo COMMIT
BEGIN TRANSACTION
ALTER TABLE dbo.Table2 WITH NOCHECK ADD CONSTRAINT FK__Table2__Table1_f__5F7E2DAC FOREIGN KEY
(

Table1_f1
) REFERENCES dbo.Table1
(

f1
)
GO
COMMIT

/***************end of scripts**********************/
Can this way work in oracle 8.0 to solve the column renaming problem?

I want to discuss this with you!

Thanks.

Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't. Received on Tue Sep 14 1999 - 07:11:32 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US