skip to Main Content

I am trying to pick up the basics of SQL and my teacher has given us this block of code to cpy and paste to create a table:

mysql> CREATE TABLE IF NOT EXISTS actors (
      ->   id SMALLINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
      ->   firstname VARCHAR(25) NOT NULL,
      ->   lastname VARCHAR(25) NOT NULL,
      ->   born DATE
      -> );

However, when I paste it and execute it, it throws an error and it doesn’t work

The error in question:
> ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-> id SMALLINT AUTO_INCREMENT PRIMARY KEY, -> firstname VARCHAR(25) N' at line 1
I tried typing it and pasting it as well and it just doesn’t work. My teacher didn’t mention anything in the documentation and just said "You just created your first table"
Can anyone help me out?

2

Answers


  1. It should work if you type it out without these: ->

    Login or Signup to reply.
  2. CREATE TABLE IF NOT EXISTS actors (
      id SMALLINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
      firstname VARCHAR(25) NOT NULL,
      lastname VARCHAR(25) NOT NULL,
      born DATE
    );
    

    Remove these arrows. I guess the teacher wanted to symbolize some whitespaces.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search