Topic
  • 2 replies
  • Latest Post - ‏2009-07-26T12:03:04Z by SystemAdmin
wakeboarder3780
wakeboarder3780
6 Posts

Pinned topic ALTER table to change "start with" value for ID

‏2009-04-21T12:52:48Z |
From the documentation I've found -
http://db.apache.org/derby/manuals/reference/sqlj26.html#HDRSII-SQLJ-81005
  • it doesn't seem this is possible.

How else are we supposed to insert default data into our derby databases? Consider 3 tables for instance:

(Author) 1-M (Author_Book) (M-1 Book)

The ID's for author and book will eventually become identity keys starting with 100, increment by 1.
I want a way to setup the tables without having the start with 100 or increment by 1, so I can enter some sample data, and then modify the column to start with 100 and increment by 1 so later everything is handled automatically.

Is this impossible with derby? If so, do I have any other similar answers?
Updated on 2009-07-26T12:03:04Z at 2009-07-26T12:03:04Z by SystemAdmin
  • wakeboarder3780
    wakeboarder3780
    6 Posts

    Re: ALTER table to change "start with" value for ID

    ‏2009-04-21T13:01:48Z  
    Nevermind, you dont' even need to alter the table. Even with the start at X, increment by Y in effect for the column, you can explicitly insert another value simply by specifying the column in the insert statement.

    For example, if you had a column ID setup as follows:
    ID INTEGER NOT NULL PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY (START WITH 100, INCREMENT BY 1),
    simply run an insert as follows

    insert into MY_TABLE(ID) values (1) ;
  • SystemAdmin
    SystemAdmin
    1525 Posts

    Re: ALTER table to change "start with" value for ID

    ‏2009-07-26T12:03:04Z  
    #

    The start-database command can be used to start an instance of the Derby network server:

    start-database http://--dbhost 0.0.0.0 --dbport 1527 --dbhome path/derby

    The default value for the host is 0.0.0.0, which allows for Derby to listen on localhost as well as the IP/hostname interfaces. The value for the dbhome property represents the location of where the Derby databases reside. The default path is <appserver_install_dir>/derby.
    #

    The asadmin stop-database command is used to shut down an instance of the Derby network server that is running:

    stop-database http://--dbhost 0.0.0.0 --dbport 1527
    ____________________________
    How to get a Solar Power Grant?