Quick question, is there an option when creating columns for a table to have a column autoincrement, for a mySQL database?
Thanks
autoincrement option when creating tables
Page 1 of 13 Replies - 5177 Views - Last Post: 10 June 2007 - 03:47 AM
Replies To: autoincrement option when creating tables
#2
Re: autoincrement option when creating tables
Posted 08 June 2007 - 03:34 PM
Yes. You can use the auto_increment keyword when naming your columns.
CREATE TABLE demo ( id int auto_increment, PRIMARY KEY(id) );
#3
Re: autoincrement option when creating tables
Posted 09 June 2007 - 08:27 AM
Yeah but how would you do that in a migration file.
like:
like:
def self.up create_table :persons do |t| t.column :id, :integer, :auto_increment # the auto_increment part is this right? end end
#4
Re: autoincrement option when creating tables
Posted 10 June 2007 - 03:47 AM
spullen, on 9 Jun, 2007 - 08:27 AM, said:
Yeah but how would you do that in a migration file.
like:
like:
def self.up create_table :persons do |t| t.column :id, :integer, :auto_increment # the auto_increment part is this right? end end
you don't need to even specify that column, the migration should create the id column automatically, makes it primary key and auto_increment.
so just don't write that line, and it'll be created for you ok?
hth
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote



|