• Mysql Table Creation Issue

    From Chris Perrault@VERT/DMINE to All on Saturday, October 22, 2011 19:06:46
    I was wondering if anyone might be able to offer some 'guidance'. I'm trying to create a few simple tables to demonstrate a bigger problem I'm having and when I try to create the first table I get my arch-nemesis, the dreaded ERROR 1064 (42000).
    Here's the really simple table I'm trying to create:
    CREATE TABLE atbl
    (
    atblnum INT UNSIGNED NOT NULL PRIMARY KEY,
    description VARCHAR NULL,
    btbl INT UNSIGNED NULL,
    ctbl INT UNSIGNED NULL
    );

    Here's the error I'm getting:
    mysql> source ~/prog/createtable.sql;
    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 'NULL,
    btbl INT UNSIGNED NULL,
    ctbl INT UNSIGNED NULL
    )' at line 4

    I swear I've created a hundred tables and I know I'm prone to stupid syntax errors, but for the life of me I can't see what I'm doing wrong here.

    Chris

    ---
    þ Synchronet þ Diamond Mine Online BBS - bbs.dmine.net
  • From Chris Perrault@VERT/DMINE to All on Saturday, October 22, 2011 20:13:42
    Re: Mysql Table Creation Issue
    By: Chris Perrault to All on Sat Oct 22 2011 07:06 pm

    Ok, problem solved.
    It was a dumb mistake as expected.
    I needed to specify a length for VARCHAR:
    description VARCHAR NULL,
    Should have been:
    description VARCHAR(20) NULL,
    Of course '20' could have been any number between 1 and 255 according to my slightly out of date book.
    Chris
    /s

    I was wondering if anyone might be able to offer some 'guidance'. I'm
    trying > create a few simple tables to demonstrate a bigger problem I'm
    having and wh
    I try to create the first table I get my arch-nemesis, the dreaded ERROR 106 (42000).
    Here's the really simple table I'm trying to create:
    CREATE TABLE atbl
    (
    atblnum INT UNSIGNED NOT NULL PRIMARY KEY,
    description VARCHAR NULL,
    btbl INT UNSIGNED NULL,
    ctbl INT UNSIGNED NULL
    );

    Here's the error I'm getting:
    mysql> source ~/prog/createtable.sql;
    ERROR 1064 (42000): You have an error in your SQL syntax; check the manual t corresponds to your MySQL server version for the right syntax to use near 'NULL,
    btbl INT UNSIGNED NULL,
    ctbl INT UNSIGNED NULL
    )' at line 4

    I swear I've created a hundred tables and I know I'm prone to stupid syntax errors, but for the life of me I can't see what I'm doing wrong here.

    Chris
    /***********************************************/
    /* cdp - Diamond Mine BBS */
    /* The Programmers' SIG @ DelphiForums */
    /* http://forums.delphiforums.com/prosig/start */ /***********************************************/

    ---
    þ Synchronet þ Diamond Mine Online BBS - bbs.dmine.net
  • From Corey@VERT/TSGC to Chris Perrault on Saturday, October 22, 2011 18:57:05
    Re: Mysql Table Creation Issue
    By: Chris Perrault to All on Sat Oct 22 2011 07:06 pm

    Subject: Mysql Table Creation Issue
    @VIA: DMINE
    @MSGID: <4EA34C86.1488.dove-prg@dmine.net>
    @TZ: c12c
    I was wondering if anyone might be able to offer some 'guidance'. I'm trying create a few simple tables to demonstrate a bigger problem I'm having and wh I try to create the first table I get my arch-nemesis, the dreaded ERROR 106 (42000).
    Here's the really simple table I'm trying to create:
    CREATE TABLE atbl
    (
    atblnum INT UNSIGNED NOT NULL PRIMARY KEY,
    description VARCHAR NULL,
    btbl INT UNSIGNED NULL,
    ctbl INT UNSIGNED NULL
    );

    Here's the error I'm getting:
    mysql> source ~/prog/createtable.sql;
    ERROR 1064 (42000): You have an error in your SQL syntax; check the manual t corresponds to your MySQL server version for the right syntax to use near 'NULL,
    btbl INT UNSIGNED NULL,
    ctbl INT UNSIGNED NULL
    )' at line 4

    I swear I've created a hundred tables and I know I'm prone to stupid syntax errors, but for the life of me I can't see what I'm doing wrong here.

    Chris


    try stronger nails.... lol

    "Practise safe Lunch, Use a Condiment"


    ---
    þ Synchronet þ Three Stooges Gentlemens Club - Las Vegas, Nv - tsgc.dyndns.org
  • From Chris Perrault@VERT/DMINE to Corey on Monday, October 24, 2011 02:26:46
    Re: Mysql Table Creation Issue
    By: Corey to Chris Perrault on Sat Oct 22 2011 06:57 pm

    Haha, sadly, I'm a better coder than woodworker. That's not saying much unfortunately...



    try stronger nails.... lol

    "Practise safe Lunch, Use a Condiment"


    /***********************************************/
    /* cdp - Diamond Mine BBS */
    /* telnet://bbs.dmine.net */
    /* The Programmers' SIG @ DelphiForums */
    /* http://forums.delphiforums.com/prosig/start */ /***********************************************/

    ---
    þ Synchronet þ Diamond Mine Online BBS - bbs.dmine.net
  • From Tracker1@VERT/TRN to Chris Perrault on Thursday, November 17, 2011 21:20:29
    On 10/22/2011 5:13 PM, Chris Perrault wrote:

    Ok, problem solved.
    It was a dumb mistake as expected.
    I needed to specify a length for VARCHAR:
    description VARCHAR NULL,
    Should have been:
    description VARCHAR(20) NULL,
    Of course '20' could have been any number between 1 and 255 according to my slightly out of date book.

    VARCHAR's and NVARCHAR's limits depend on the database in particular... in this case MySQL (still 255 limit, 256 - 1 for null byte.)... there may also be limits with regards to an index size on a varchar field.

    MS-SQL introduced a VARCHAR/NVARCHAR(MAX) that basically combines varchar/nvarchar, and text/ntext for example.

    YMMV.

    --
    Michael J. Ryan - http://tracker1.info/

    ---
    þ Synchronet þ Roughneck BBS - telnet://roughneckbbs.com - www.roughneckbbs.com
  • From Chris Perrault@VERT/DMINE to Tracker1 on Friday, November 18, 2011 16:37:55
    Re: Re: Mysql Table Creation Issue
    By: Tracker1 to Chris Perrault on Thu Nov 17 2011 09:20 pm

    Hi Michael,

    MS-SQL introduced a VARCHAR/NVARCHAR(MAX) that basically combines varchar/nvarchar, and text/ntext for example.

    YMMV.

    --

    This was the first I heard of NVARCHAR. I did a quick google of it and it sounds like the only difference is that it stores unicode characters. Does that sound right?

    /***********************************************/
    /* cdp - Diamond Mine BBS */
    /* telnet://bbs.dmine.net */
    /* The Programmers' SIG @ DelphiForums */
    /* http://forums.delphiforums.com/prosig/start */ /***********************************************/

    ---
    þ Synchronet þ Diamond Mine Online BBS - bbs.dmine.net
  • From Tracker1@VERT/TRN to Chris Perrault on Friday, December 02, 2011 21:39:12
    On 11/18/2011 2:37 PM, Chris Perrault wrote:
    Hi Michael,

    MS-SQL introduced a VARCHAR/NVARCHAR(MAX) that basically combines
    varchar/nvarchar, and text/ntext for example.

    YMMV.

    This was the first I heard of NVARCHAR. I did a quick google of it and it sounds like the only difference is that it stores unicode characters. Does that
    sound right?

    That's correct, essentially characters assume utf-16 format, so no encoding issues.

    --
    Michael J. Ryan - http://tracker1.info/

    ---
    þ Synchronet þ Roughneck BBS - telnet://roughneckbbs.com - www.roughneckbbs.com