SitePoint Sponsor

User Tag List

Results 1 to 10 of 10

Thread: SQL Problem

  1. #1
    SitePoint Guru
    Join Date
    Aug 2004
    Location
    Port Sunlight
    Posts
    815
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    SQL Problem

    Hi,

    I am trying out this tutorial:

    http://www.rails4days.pwp.blueyonder...Rails4Days.pdf

    CREATE TABLE 'categories' (
    'id' smallint(5) unsigned NOT NULL auto_increment,
    'category' varchar(20) NOT NULL default '',
    'created_on' timestamp(14) NOT NULL,
    'updated_on' timestamp(14) NOT NULL,
    PRIMARY KEY ('id'),
    UNIQUE KEY 'category_key' ('category')
    ) TYPE=MyISAM COMMENT='List of categories';

    It gives me an error, saying SQL execution error # 1064.

    Anyone know why?

  2. #2
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,236
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    If you're using a version of MySQL greater than 4.1 you have to use ENGINE=MyISAM, not TYPE.

  3. #3
    SitePoint Guru
    Join Date
    Aug 2004
    Location
    Port Sunlight
    Posts
    815
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok, however it is still giving me an error:

    I have attached a screenshot.

    Also, I wasn't sure if this should have gone in MySQL or Ruby, because it was a ruby tutorial, I thought it may have gone there.
    Attached Images Attached Images

  4. #4
    SitePoint Guru
    Join Date
    Aug 2005
    Posts
    986
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try a migration:

    Code:
    create_table :categories do |t|
        t.column :category, :string
        t.column :created_on, :datetime
        t.column :updated_on, :datetime
    end

  5. #5
    SitePoint Guru
    Join Date
    Aug 2004
    Location
    Port Sunlight
    Posts
    815
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What's a migration?

    Also I would like to use this SQL, because i'm following a tutorial and I don't really want to sidestep it,

  6. #6
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,236
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by NickToye
    What's a migration?

    Also I would like to use this SQL, because i'm following a tutorial and I don't really want to sidestep it,
    Migrations are the preferred way to work with databases in Rails now, since a migration isn't DBMS-specific.

  7. #7
    SitePoint Guru
    Join Date
    Aug 2004
    Location
    Port Sunlight
    Posts
    815
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah, so its a more simplified way of creating SQL, or a more Rails/Ruby native way of creating data.

    Is that right?

  8. #8
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,236
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by NickToye
    Yeah, so its a more simplified way of creating SQL, or a more Rails/Ruby native way of creating data.

    Is that right?
    Both, with the added benefit of being portable (i.e. for the most part you'd be able to use the same migration for SQLite or MySQL or SQL Server).

  9. #9
    SitePoint Guru
    Join Date
    Aug 2004
    Location
    Port Sunlight
    Posts
    815
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It looks good, I like the fact that it makes logical sense too.

  10. #10
    Employed Again Viflux's Avatar
    Join Date
    May 2003
    Location
    London, On.
    Posts
    1,130
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Which IDE are you using btw? Looks sharp


Bookmarks

Posting Permissions

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