Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!

Creating database from DDL statements in an sql

Discussion in 'Information Technology' started by torch_music, Nov 16, 2005.

  1. torch_music

    torch_music
    Expand Collapse
    Guest

    I have a file of DDL statements that I want to execute. Is there an easy way
    of doing this? I have found that if I start a new query, there is a DDL
    option but it only lets me copy and paste one statement at a time, which is a
    bit laborious.
    Thanks
     
  2. Loading...

    Similar Threads Forum Date
    Canada Ottawa weighs creating ambassador for religious freedom Breaking News Oct 4, 2011
    India SGPC Accused of Creating a Row Breaking News Jan 20, 2011
    Pacific International Gathering of Young Sikhs Focuses on Creating Good Citizens Breaking News Jan 8, 2011
    Are We Creating New Devtas? Sikh Sikhi Sikhism Aug 21, 2009
    Sikh News Sharif warns against creating instability in Punjab (Express India) Breaking News Sep 19, 2008

  3. Brendan Reynolds

    Brendan Reynolds
    Expand Collapse
    Guest

    What sort of file? Is it a structured format such as a database or a
    spreadsheet, or an unstructured format such as a free-form text file? Is
    there a consistent and unambiguous separator between each SQL statement in
    the file?

    --
    Brendan Reynolds

    "torch_music" <torchmusic@discussions.microsoft.com> wrote in message
    news:66F89E57-76E2-4955-A4E7-7147648E4357@microsoft.com...
    >I have a file of DDL statements that I want to execute. Is there an easy
    >way
    > of doing this? I have found that if I start a new query, there is a DDL
    > option but it only lets me copy and paste one statement at a time, which
    > is a
    > bit laborious.
    > Thanks
     
  4. torch_music

    torch_music
    Expand Collapse
    Guest

    It is a generated sql file from a design program, but its pretty similar to a
    handcrafted creation script.

    A sample of part of the file is:

    -- Create a Database table to represent the "Card" entity.
    CREATE TABLE Card(
    CardName VARCHAR(50) NOT NULL,
    RulesText INTEGER,
    fk1_TypeCode INTEGER NOT NULL,
    fk2_ColourCode VARCHAR(1) NOT NULL,
    -- Specify the PRIMARY KEY constraint for table "Card".
    -- This indicates which attribute(s) uniquely identify each row of data.
    CONSTRAINT pk_Card PRIMARY KEY (CardName)
    );

    -- Create a Database table to represent the "Expansion" entity.
    CREATE TABLE Expansion(
    Code VARCHAR(3) NOT NULL,
    ExpansionName VARCHAR(50) NOT NULL,
    ExpansionSymbol BLOB,
    -- Specify the PRIMARY KEY constraint for table "Expansion".
    -- This indicates which attribute(s) uniquely identify each row of data.
    CONSTRAINT pk_Expansion PRIMARY KEY (Code)
    );

    -- Create a Database table to represent the "SetList" entity.
    CREATE TABLE SetList(
    CardNo INTEGER,
    FlavourText VARCHAR(120),
    fk1_Code VARCHAR(3) NOT NULL,
    fk2_CardName VARCHAR(50) NOT NULL,
    fk3_ArtistCode INTEGER NOT NULL,
    fk4_RarityCode VARCHAR(1) NOT NULL
    );

    If I were using oracle I would just go into sqlplus and enter @filename
    where filename is the name of the sql file with the commands in it. The
    commands would execute and the tables would be created. Is there a similar
    way of doing this in Access?


    "Brendan Reynolds" wrote:

    > What sort of file? Is it a structured format such as a database or a
    > spreadsheet, or an unstructured format such as a free-form text file? Is
    > there a consistent and unambiguous separator between each SQL statement in
    > the file?
    >
    > --
    > Brendan Reynolds
    >
    > "torch_music" <torchmusic@discussions.microsoft.com> wrote in message
    > news:66F89E57-76E2-4955-A4E7-7147648E4357@microsoft.com...
    > >I have a file of DDL statements that I want to execute. Is there an easy
    > >way
    > > of doing this? I have found that if I start a new query, there is a DDL
    > > option but it only lets me copy and paste one statement at a time, which
    > > is a
    > > bit laborious.
    > > Thanks

    >
    >
    >
     
  5. peregenem@jetemail.net

    peregenem@jetemail.net
    Expand Collapse
    Guest

    torch_music wrote:
    > It is a generated sql file from a design program, but its pretty similar to a
    > handcrafted creation script.


    In Jet, you must execute each distinct SQL statement separately :(

    There is no built-in tool to execute a DDL script :(

    The code required to parse a text file using the semi colon to separate
    each statement using the semi colon is trivial. You could then execute
    each statement against a connection in code; again, trivial :)

    Note that you will have problems because you have written SQL syntax
    which Jet does not possess e.g. BLOB is SQL-99 and comments are SQL-92
    but Jet is not compliant with either standard :(
     
  6. Brendan Reynolds

    Brendan Reynolds
    Expand Collapse
    Guest

    In addition to the points already made elsewhere in this thread, JET SQL
    does not support comments. You're going to have to make significant
    modifications to those SQL statements before they'll be compatible with JET.
    As you need to make those modifications anyway, you might as well remove the
    line breaks so that each SQL statement is on one line. Then you'll be able
    to read them using Line Input statements and won't have to parse them.

    --
    Brendan Reynolds

    "torch_music" <torchmusic@discussions.microsoft.com> wrote in message
    news:B8042A8B-5538-49CF-AF3A-8EE15666D5D9@microsoft.com...
    > It is a generated sql file from a design program, but its pretty similar
    > to a
    > handcrafted creation script.
    >
    > A sample of part of the file is:
    >
    > -- Create a Database table to represent the "Card" entity.
    > CREATE TABLE Card(
    > CardName VARCHAR(50) NOT NULL,
    > RulesText INTEGER,
    > fk1_TypeCode INTEGER NOT NULL,
    > fk2_ColourCode VARCHAR(1) NOT NULL,
    > -- Specify the PRIMARY KEY constraint for table "Card".
    > -- This indicates which attribute(s) uniquely identify each row of data.
    > CONSTRAINT pk_Card PRIMARY KEY (CardName)
    > );
    >
    > -- Create a Database table to represent the "Expansion" entity.
    > CREATE TABLE Expansion(
    > Code VARCHAR(3) NOT NULL,
    > ExpansionName VARCHAR(50) NOT NULL,
    > ExpansionSymbol BLOB,
    > -- Specify the PRIMARY KEY constraint for table "Expansion".
    > -- This indicates which attribute(s) uniquely identify each row of data.
    > CONSTRAINT pk_Expansion PRIMARY KEY (Code)
    > );
    >
    > -- Create a Database table to represent the "SetList" entity.
    > CREATE TABLE SetList(
    > CardNo INTEGER,
    > FlavourText VARCHAR(120),
    > fk1_Code VARCHAR(3) NOT NULL,
    > fk2_CardName VARCHAR(50) NOT NULL,
    > fk3_ArtistCode INTEGER NOT NULL,
    > fk4_RarityCode VARCHAR(1) NOT NULL
    > );
    >
    > If I were using oracle I would just go into sqlplus and enter @filename
    > where filename is the name of the sql file with the commands in it. The
    > commands would execute and the tables would be created. Is there a
    > similar
    > way of doing this in Access?
    >
    >
    > "Brendan Reynolds" wrote:
    >
    >> What sort of file? Is it a structured format such as a database or a
    >> spreadsheet, or an unstructured format such as a free-form text file? Is
    >> there a consistent and unambiguous separator between each SQL statement
    >> in
    >> the file?
    >>
    >> --
    >> Brendan Reynolds
    >>
    >> "torch_music" <torchmusic@discussions.microsoft.com> wrote in message
    >> news:66F89E57-76E2-4955-A4E7-7147648E4357@microsoft.com...
    >> >I have a file of DDL statements that I want to execute. Is there an
    >> >easy
    >> >way
    >> > of doing this? I have found that if I start a new query, there is a
    >> > DDL
    >> > option but it only lets me copy and paste one statement at a time,
    >> > which
    >> > is a
    >> > bit laborious.
    >> > Thanks

    >>
    >>
    >>
     
  7. torch_music

    torch_music
    Expand Collapse
    Guest

    OK, thanks guys.

    "Brendan Reynolds" wrote:

    > In addition to the points already made elsewhere in this thread, JET SQL
    > does not support comments. You're going to have to make significant
    > modifications to those SQL statements before they'll be compatible with JET.
    > As you need to make those modifications anyway, you might as well remove the
    > line breaks so that each SQL statement is on one line. Then you'll be able
    > to read them using Line Input statements and won't have to parse them.
    >
    > --
    > Brendan Reynolds
    >
    > "torch_music" <torchmusic@discussions.microsoft.com> wrote in message
    > news:B8042A8B-5538-49CF-AF3A-8EE15666D5D9@microsoft.com...
    > > It is a generated sql file from a design program, but its pretty similar
    > > to a
    > > handcrafted creation script.
    > >
    > > A sample of part of the file is:
    > >
    > > -- Create a Database table to represent the "Card" entity.
    > > CREATE TABLE Card(
    > > CardName VARCHAR(50) NOT NULL,
    > > RulesText INTEGER,
    > > fk1_TypeCode INTEGER NOT NULL,
    > > fk2_ColourCode VARCHAR(1) NOT NULL,
    > > -- Specify the PRIMARY KEY constraint for table "Card".
    > > -- This indicates which attribute(s) uniquely identify each row of data.
    > > CONSTRAINT pk_Card PRIMARY KEY (CardName)
    > > );
    > >
    > > -- Create a Database table to represent the "Expansion" entity.
    > > CREATE TABLE Expansion(
    > > Code VARCHAR(3) NOT NULL,
    > > ExpansionName VARCHAR(50) NOT NULL,
    > > ExpansionSymbol BLOB,
    > > -- Specify the PRIMARY KEY constraint for table "Expansion".
    > > -- This indicates which attribute(s) uniquely identify each row of data.
    > > CONSTRAINT pk_Expansion PRIMARY KEY (Code)
    > > );
    > >
    > > -- Create a Database table to represent the "SetList" entity.
    > > CREATE TABLE SetList(
    > > CardNo INTEGER,
    > > FlavourText VARCHAR(120),
    > > fk1_Code VARCHAR(3) NOT NULL,
    > > fk2_CardName VARCHAR(50) NOT NULL,
    > > fk3_ArtistCode INTEGER NOT NULL,
    > > fk4_RarityCode VARCHAR(1) NOT NULL
    > > );
    > >
    > > If I were using oracle I would just go into sqlplus and enter @filename
    > > where filename is the name of the sql file with the commands in it. The
    > > commands would execute and the tables would be created. Is there a
    > > similar
    > > way of doing this in Access?
    > >
    > >
    > > "Brendan Reynolds" wrote:
    > >
    > >> What sort of file? Is it a structured format such as a database or a
    > >> spreadsheet, or an unstructured format such as a free-form text file? Is
    > >> there a consistent and unambiguous separator between each SQL statement
    > >> in
    > >> the file?
    > >>
    > >> --
    > >> Brendan Reynolds
    > >>
    > >> "torch_music" <torchmusic@discussions.microsoft.com> wrote in message
    > >> news:66F89E57-76E2-4955-A4E7-7147648E4357@microsoft.com...
    > >> >I have a file of DDL statements that I want to execute. Is there an
    > >> >easy
    > >> >way
    > >> > of doing this? I have found that if I start a new query, there is a
    > >> > DDL
    > >> > option but it only lets me copy and paste one statement at a time,
    > >> > which
    > >> > is a
    > >> > bit laborious.
    > >> > Thanks
    > >>
    > >>
    > >>

    >
    >
    >
     

Share This Page