How to drop and then create a table during runtime in oracle9i

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gracepaul
    New Member
    • Jul 2008
    • 28

    How to drop and then create a table during runtime in oracle9i

    hi all,

    I want to drop a table and then create it again during runtime in oracle9i.

    The equivalent code that can be used with SQL is as follows

    if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[mstCourse]') and OBJECTPROPERTY( id, N'IsUserTable') = 1)
    drop table [dbo].[mstCourse]
    GO

    CREATE TABLE [dbo].[mstCourse] (
    [cuCode] [int] NOT NULL ,
    [cuName] [varchar] (50) COLLATE SQL_Latin1_Gene ral_CP1_CI_AS NULL ,
    [cuShName] [varchar] (15) COLLATE SQL_Latin1_Gene ral_CP1_CI_AS NULL ,
    [cuDuration] [int] NULL ,
    [cuRemarks] [varchar] (50) COLLATE SQL_Latin1_Gene ral_CP1_CI_AS NULL
    ) ON [PRIMARY]
    GO



    But in oracle it didn't work well.
    If anybody have a solution please reply as early as possible

    Thanks in advance

    Grace
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    you need to use EXECUTE IMMEDIATE for that.

    Comment

    Working...