Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2004
    Location
    Germany
    Posts
    136

    Red face Unanswered: How to standardize tables

    Hello All,

    How can i standardize tables in my database,
    if i want to achieve the next format for each table:

    Column_1: TABLE_ID (INTEGER, AUTOINCREMENT , PRIMARY KEY),

    Column_2: ....
    ....
    different by each table

    Column_n: CREATE_DATE (DATE, select SYSDATE from DUAL).




    Thanks In Advance

  2. #2
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1

    Re: How to standardize tables

    Use a template for your CREATE TABLE script? Something like:
    PHP Code:
    CREATE TABLE xxx
    table_id INTEGER CONSTRAINT xxx_pk PRIMARY KEY
    create_date DATE
    -- Add your columns here
    );

    CREATE SEQUENCE xxx_seq;

    CREATE TRIGGER xxx_trg 
    BEFORE INSERT ON xxx
    FOR EACH ROW
    BEGIN
      SELECT xxx_seq
    .NEXTVALSYSDATE
        INTO  
    :new.table_id, :new.create_date
        FROM DUAL
    ;
    END;

    BTW, putting CREATE_DATE at the end is not ideal, because it is always populated. It is best to have columns that can be NULL last to conserve space.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •