SQL Statement help

Discussion in 'Databases' started by obenix, Nov 15, 2005.

  1. #1
    I'm writing a restore function for my application and basically it drops a table and recreates based on an earlier backup. When I run the SQL query, an error occured. Can you please tell me what's wrong with my SQL statement here?

    drop table if exists tbl_transaction;
    create table tbl_transaction (
      trans_num int(11) not null auto_increment,
      transtype_id varchar(100) not null,
      license_id varchar(100) not null,
      trans_qty int(11) default '0' not null,
      trans_date date default '0000-00-00' not null,
      trans_alloc_date date default '0000-00-00' not null,
      trans_po_num varchar(100),
      trans_po_date date default '0000-00-00',
      trans_do_num varchar(100),
      trans_do_date date default '0000-00-00',
      trans_inv_num varchar(100),
      trans_inv_date date default '0000-00-00',
      trans_timestamp timestamp default 'CURRENT_TIMESTAMP',
      trans_remarks varchar(100)
    );
    Code (markup):

     
    obenix, Nov 15, 2005 IP
    Nintendo likes this.
  2. norfstar

    norfstar Peon

    Messages:
    1,154
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I think that it might be the case that auto_increment columns need to be key.
     
    norfstar, Nov 16, 2005 IP
    obenix likes this.
  3. obenix

    obenix Eats an apple a day......

    Messages:
    2,236
    Likes Received:
    180
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Oops!! Trying it.. :)

    --edit--
    Yes, it worked!! Thanks for the help. Greened you :D
     
    obenix, Nov 16, 2005 IP
    norfstar likes this.