Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2013
    Posts
    41

    Unanswered: What's wrong with the following query?

    Hi,

    I'm trying to create a table in MySQL from the following query:

    Code:
    CREATE TABLE DEPT
           (DEPTNO SMALLINT CONSTRAINT PK_DEPT_DEPTNO PRIMARY KEY,
            LOC VARCHAR2(13) );
            DNAME VARCHAR2(14),

    but I'm getting an error:

    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 'CONSTRAINT PK_DEPT_DEPTNO PRIMARY KEY, DNAME VARCHAR2(14),LOC V' at line 2


    can anyone please help me what's wrong?

  2. #2
    Join Date
    Feb 2008
    Location
    Japan
    Posts
    3,483
    First of all,
    strange code
    Code:
            LOC VARCHAR2(13) );
            DNAME VARCHAR2(14),
    LOC and DNAME might be reversed.
    But, why?


    Where did you found VARCHAR2 datatype?

  3. #3
    Join Date
    Nov 2003
    Posts
    2,935
    Provided Answers: 12
    Quote Originally Posted by tonkuma View Post
    Where did you found VARCHAR2 datatype?
    That's an Oracle datatype
    I will not read nor answer questions where the SQL code is messy and not formatted properly using [code] tags: http://www.dbforums.com/misc.php?do=bbcode#code

    Tips for good questions:

    http://tkyte.blogspot.de/2005/06/how...questions.html
    http://wiki.postgresql.org/wiki/SlowQueryQuestions
    http://catb.org/esr/faqs/smart-questions.html

  4. #4
    Join Date
    Sep 2009
    Location
    San Sebastian, Spain
    Posts
    880
    The problem is that a ; terminates the command and tries to execute it. This is incorrect and should be as follows:

    Code:
    CREATE TABLE DEPT
           (DEPTNO SMALLINT CONSTRAINT PK_DEPT_DEPTNO PRIMARY KEY,
            DNAME VARCHAR2(14),
            LOC VARCHAR2(13) );
    Ronan Cashell
    Certified Oracle DBA/Certified MySQL Expert (DBA & Cluster DBA)
    http://www.it-iss.com
    Follow me on Twitter

Posting Permissions

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