Results 1 to 12 of 12
  1. #1
    Join Date
    Sep 2008
    Posts
    34

    Unanswered: Help with CREATING a table

    Code:
    CREATE TABLE `iesfile`.`drivers` ( 'DRCODE' CHAR(6) NOT NULL, 'DRNAME' CHAR(25) NOT NULL, 'DRSHNM' CHAR(8) NOT NULL, 'DRADD' CHAR(25) NOT NULL, 'DRCITY' CHAR(15) NOT NULL, 'DRST' CHAR(2) NOT NULL, 'DRZIP' CHAR(5) NOT NULL, 'DRZP2' CHAR(4) NOT NULL, 'DRAC' DECIMAL(3) NOT NULL, 'DRPHON' DECIMAL(7) NOT NULL, 'DRSS' CHAR(9) NOT NULL, 'DRSUPR' CHAR(6) NOT NULL, 'DRFMGR' CHAR(6) NOT NULL, 'DRCRED' DECIMAL(7) NOT NULL, 'DRCRET' CHAR(4) NOT NULL, 'DRCREI' CHAR(3) NOT NULL, 'DRUPDD' DECIMAL(7) NOT NULL, 'DRUPDT' CHAR(4) NOT NULL, 'DRUPDI' CHAR(3) NOT NULL, 'DRCO#' CHAR(3) NOT NULL, 'DRDV#' CHAR(3) NOT NULL, 'DRTM#' CHAR(6) NOT NULL, 'DRBDAT' DECIMAL(7) NOT NULL, 'DRHDAT' DECIMAL(7) NOT NULL, 'DRRDAT' DECIMAL(7) NOT NULL, 'DRTDAT' DECIMAL(7) NOT NULL, 'DRLEXP' DECIMAL(7) NOT NULL, 'DRPEXP' DECIMAL(7) NOT NULL, 'DRLICE' CHAR(25) NOT NULL, 'DRTYPE' CHAR(1) NOT NULL, 'DRSTAT' CHAR(1) NOT NULL, 'DRPRVO' CHAR(7) NOT NULL, 'DRPDSP' CHAR(2) NOT NULL, 'DRORD#' CHAR(7) NOT NULL, 'DRDISP' CHAR(2) NOT NULL, 'DRUNIT' CHAR(6) NOT NULL, 'DRDCTY' CHAR(4) NOT NULL, 'DRDST' CHAR(2) NOT NULL, 'DRMSG' CHAR(1) NOT NULL, 'DRDLT' CHAR(1) NOT NULL, 'DRENAM' CHAR(25) NOT NULL, 'DRENUM' CHAR(15) NOT NULL, 'DRPHAZ' CHAR(2) NOT NULL, 'DRNUNT' CHAR(6) NOT NULL, 'DRSPS' CHAR(10) NOT NULL, 'DRMISC' CHAR(25) NOT NULL, 'DRFC' CHAR(1) NOT NULL, 'DRHOME' CHAR(6) NOT NULL, 'DRVOIC' CHAR(4) NOT NULL, 'DRJIT' CHAR(1) NOT NULL, 'DRTRAN' CHAR(1) NOT NULL, 'DR1DTE' DECIMAL(7) NOT NULL, 'DR1MIL' NUMERIC(4) NOT NULL, 'DR2DTE' DECIMAL(7) NOT NULL, 'DR2MIL' NUMERIC(4) NOT NULL, 'DR3DTE' DECIMAL(7) NOT NULL, 'DR3MIL' NUMERIC(4) NOT NULL, 'DR4DTE' DECIMAL(7) NOT NULL, 'DR4MIL' NUMERIC(4) NOT NULL, 'DR5DTE' DECIMAL(7) NOT NULL, 'DR5MIL' NUMERIC(4) NOT NULL, 'DR6DTE' DECIMAL(7) NOT NULL, 'DR6MIL' NUMERIC(4) NOT NULL, 'DR7DTE' DECIMAL(7) NOT NULL, 'DR7MIL' NUMERIC(4) NOT NULL, 'DRDBAL' DECIMAL(7) NOT NULL, 'DRCBAL' DECIMAL(7) NOT NULL, 'DRMBPW' NUMERIC(4) NOT NULL, 'DRLPAY' DECIMAL(9) NOT NULL, 'DRCARD' CHAR(20) NOT NULL, 'DRSOLO' DECIMAL(7) NOT NULL, 'DRLTDT' DECIMAL(7) NOT NULL, 'DRNTDT' DECIMAL(7) NOT NULL, 'DRSMKR' CHAR(1) NOT NULL, 'DRRACE' CHAR(1) NOT NULL, 'DRSEX' CHAR(1) NOT NULL, 'DRLONG' CHAR(1) NOT NULL, 'DRLGDT' DECIMAL(7) NOT NULL, 'DRTYCD' CHAR(4) NOT NULL, 'DRTERM' CHAR(6) NOT NULL, 'DRPTAD' DECIMAL(7) NOT NULL, 'DRPTAT' CHAR(4) NOT NULL, 'DRHFM' DECIMAL(2) NOT NULL, 'DRSPCT' CHAR(4) NOT NULL, 'DRSPST' CHAR(2) NOT NULL, 'DRSDTE' DECIMAL(7) NOT NULL, 'DRSTME' CHAR(4) NOT NULL, 'DRPRIO' CHAR(1) NOT NULL, 'DRDTED' DECIMAL(7) NOT NULL, 'DRTMED' CHAR(4) NOT NULL, 'DRUNTA' CHAR(1) NOT NULL, 'DRUSR1' DECIMAL(7) NOT NULL, 'DRUSR2' CHAR(25) NOT NULL, 'DRUSR3' CHAR(25) NOT NULL, 'DRUSR4' CHAR(25) NOT NULL, 'DRFIL' CHAR(12) NOT NULL, ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
    
    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 ''DRCODE' CHAR(6) NOT NULL, 'DRNAME' CHAR(25) NOT NULL, 'DRSHNM' CHAR(8) NOT NULL' at line 1
    Can anyone tell me why this is not working?
    Thanks!

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    take a look at where the error message says it happens

    it happens right after the opening parenthesis for the table definition

    what follows should be a column name

    what it found was a character string

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Jun 2008
    Location
    pakistan
    Posts
    109
    I have found your error now copy this code and paste as you want cause you use signle quote before and after the name of column actually you have to use this sign ` not ' sigle quote

    copy the code and paste it it will make table as you want
    Code:
    CREATE TABLE `iesfile`.`drivers` ( `DRCODE` CHAR(6) NOT NULL,
     `DRNAME` CHAR(25) NOT NULL, `DRSHNM` CHAR(8) NOT NULL, `DRADD` CHAR(25) NOT NULL, `DRCITY` CHAR(15) NOT NULL, `DRST` CHAR(2) NOT NULL, `DRZIP` CHAR(5) NOT NULL, `DRZP2` CHAR(4) NOT NULL, `DRAC` DECIMAL(3) NOT NULL, `DRPHON` DECIMAL(7) NOT NULL, `DRSS` CHAR(9) NOT NULL, `DRSUPR` CHAR(6) NOT NULL, `DRFMGR` CHAR(6) NOT NULL, `DRCRED` DECIMAL(7) NOT NULL, `DRCRET` CHAR(4) NOT NULL, `DRCREI` CHAR(3) NOT NULL, `DRUPDD` DECIMAL(7) NOT NULL, `DRUPDT` CHAR(4) NOT NULL, `DRUPDI` CHAR(3) NOT NULL, `DRCO#` CHAR(3) NOT NULL, `DRDV#` CHAR(3) NOT NULL, `DRTM#` CHAR(6) NOT NULL, `DRBDAT` DECIMAL(7) NOT NULL, `DRHDAT` DECIMAL(7) NOT NULL, `DRRDAT` DECIMAL(7) NOT NULL, `DRTDAT` DECIMAL(7) NOT NULL, `DRLEXP` DECIMAL(7) NOT NULL, `DRPEXP` DECIMAL(7) NOT NULL, `DRLICE` CHAR(25) NOT NULL, `DRTYPE` CHAR(1) NOT NULL, `DRSTAT` CHAR(1) NOT NULL, `DRPRVO` CHAR(7) NOT NULL, `DRPDSP` CHAR(2) NOT NULL, `DRORD#` CHAR(7) NOT NULL, `DRDISP` CHAR(2) NOT NULL, `DRUNIT` CHAR(6) NOT NULL, `DRDCTY` CHAR(4) NOT NULL, `DRDST` CHAR(2) NOT NULL, `DRMSG` CHAR(1) NOT NULL, `DRDLT` CHAR(1) NOT NULL, `DRENAM` CHAR(25) NOT NULL, `DRENUM` CHAR(15) NOT NULL, `DRPHAZ` CHAR(2) NOT NULL, `DRNUNT` CHAR(6) NOT NULL, `DRSPS` CHAR(10) NOT NULL, `DRMISC` CHAR(25) NOT NULL, `DRFC` CHAR(1) NOT NULL, `DRHOME` CHAR(6) NOT NULL, `DRVOIC` CHAR(4) NOT NULL, `DRJIT` CHAR(1) NOT NULL, `DRTRAN` CHAR(1) NOT NULL, `DR1DTE` DECIMAL(7) NOT NULL, `DR1MIL` NUMERIC(4) NOT NULL, `DR2DTE` DECIMAL(7) NOT NULL, `DR2MIL` NUMERIC(4) NOT NULL, `DR3DTE` DECIMAL(7) NOT NULL, `DR3MIL` NUMERIC(4) NOT NULL, `DR4DTE` DECIMAL(7) NOT NULL, `DR4MIL` NUMERIC(4) NOT NULL, `DR5DTE` DECIMAL(7) NOT NULL, `DR5MIL` NUMERIC(4) NOT NULL, `DR6DTE` DECIMAL(7) NOT NULL, `DR6MIL` NUMERIC(4) NOT NULL, `DR7DTE` DECIMAL(7) NOT NULL, `DR7MIL` NUMERIC(4) NOT NULL, `DRDBAL` DECIMAL(7) NOT NULL, `DRCBAL` DECIMAL(7) NOT NULL, `DRMBPW` NUMERIC(4) NOT NULL, `DRLPAY` DECIMAL(9) NOT NULL, `DRCARD` CHAR(20) NOT NULL, `DRSOLO` DECIMAL(7) NOT NULL, `DRLTDT` DECIMAL(7) NOT NULL, `DRNTDT` DECIMAL(7) NOT NULL, `DRSMKR` CHAR(1) NOT NULL, `DRRACE` CHAR(1) NOT NULL, `DRSEX` CHAR(1) NOT NULL, `DRLONG` CHAR(1) NOT NULL, `DRLGDT` DECIMAL(7) NOT NULL, `DRTYCD` CHAR(4) NOT NULL, `DRTERM` CHAR(6) NOT NULL, `DRPTAD` DECIMAL(7) NOT NULL, `DRPTAT` CHAR(4) NOT NULL, `DRHFM` DECIMAL(2) NOT NULL, `DRSPCT` CHAR(4) NOT NULL, `DRSPST` CHAR(2) NOT NULL, `DRSDTE` DECIMAL(7) NOT NULL, `DRSTME` CHAR(4) NOT NULL, `DRPRIO` CHAR(1) NOT NULL, `DRDTED` DECIMAL(7) NOT NULL, `DRTMED` CHAR(4) NOT NULL, `DRUNTA` CHAR(1) NOT NULL, `DRUSR1` DECIMAL(7) NOT NULL, `DRUSR2` CHAR(25) NOT NULL, `DRUSR3` CHAR(25) NOT NULL, `DRUSR4` CHAR(25) NOT NULL, `DRFIL` CHAR(12) NOT NULL );

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by don_log View Post
    actually you have to use this sign `
    actually, no you don't

    you can, but in fact it is better if you don't use it at all unless you have to

    and you only have to when the column name contains special characters as in the examples shown below in blue
    Code:
    CREATE TABLE iesfile.drivers 
    ( DRCODE CHAR(6) NOT NULL
    , DRNAME CHAR(25) NOT NULL
    , DRSHNM CHAR(8) NOT NULL
    , DRADD  CHAR(25) NOT NULL
    , DRCITY CHAR(15) NOT NULL
    , DRST   CHAR(2) NOT NULL
    , DRZIP  CHAR(5) NOT NULL
    , DRZP2  CHAR(4) NOT NULL
    , DRAC   DECIMAL(3) NOT NULL
    , DRPHON DECIMAL(7) NOT NULL
    , DRSS   CHAR(9) NOT NULL
    , DRSUPR CHAR(6) NOT NULL
    , DRFMGR CHAR(6) NOT NULL
    , DRCRED DECIMAL(7) NOT NULL
    , DRCRET CHAR(4) NOT NULL
    , DRCREI CHAR(3) NOT NULL
    , DRUPDD DECIMAL(7) NOT NULL
    , DRUPDT CHAR(4) NOT NULL
    , DRUPDI CHAR(3) NOT NULL
    , `DRCO#` CHAR(3) NOT NULL
    , `DRDV#` CHAR(3) NOT NULL
    , `DRTM#` CHAR(6) NOT NULL
    , DRBDAT DECIMAL(7) NOT NULL
    , DRHDAT DECIMAL(7) NOT NULL
    , DRRDAT DECIMAL(7) NOT NULL
    , DRTDAT DECIMAL(7) NOT NULL
    , DRLEXP DECIMAL(7) NOT NULL
    , DRPEXP DECIMAL(7) NOT NULL
    , DRLICE CHAR(25) NOT NULL
    , DRTYPE CHAR(1) NOT NULL
    , DRSTAT CHAR(1) NOT NULL
    , DRPRVO CHAR(7) NOT NULL
    , DRPDSP CHAR(2) NOT NULL
    , DRORD# CHAR(7) NOT NULL
    , DRDISP CHAR(2) NOT NULL
    , DRUNIT CHAR(6) NOT NULL
    , DRDCTY CHAR(4) NOT NULL
    , DRDST  CHAR(2) NOT NULL
    , DRMSG  CHAR(1) NOT NULL
    , DRDLT  CHAR(1) NOT NULL
    , DRENAM CHAR(25) NOT NULL
    , DRENUM CHAR(15) NOT NULL
    , DRPHAZ CHAR(2) NOT NULL
    , DRNUNT CHAR(6) NOT NULL
    , DRSPS  CHAR(10) NOT NULL
    , DRMISC CHAR(25) NOT NULL
    , DRFC   CHAR(1) NOT NULL
    , DRHOME CHAR(6) NOT NULL
    , DRVOIC CHAR(4) NOT NULL
    , DRJIT  CHAR(1) NOT NULL
    , DRTRAN CHAR(1) NOT NULL
    , DR1DTE DECIMAL(7) NOT NULL
    , DR1MIL NUMERIC(4) NOT NULL
    , DR2DTE DECIMAL(7) NOT NULL
    , DR2MIL NUMERIC(4) NOT NULL
    , DR3DTE DECIMAL(7) NOT NULL
    , DR3MIL NUMERIC(4) NOT NULL
    , DR4DTE DECIMAL(7) NOT NULL
    , DR4MIL NUMERIC(4) NOT NULL
    , DR5DTE DECIMAL(7) NOT NULL
    , DR5MIL NUMERIC(4) NOT NULL
    , DR6DTE DECIMAL(7) NOT NULL
    , DR6MIL NUMERIC(4) NOT NULL
    , DR7DTE DECIMAL(7) NOT NULL
    , DR7MIL NUMERIC(4) NOT NULL
    , DRDBAL DECIMAL(7) NOT NULL
    , DRCBAL DECIMAL(7) NOT NULL
    , DRMBPW NUMERIC(4) NOT NULL
    , DRLPAY DECIMAL(9) NOT NULL
    , DRCARD CHAR(20) NOT NULL
    , DRSOLO DECIMAL(7) NOT NULL
    , DRLTDT DECIMAL(7) NOT NULL
    , DRNTDT DECIMAL(7) NOT NULL
    , DRSMKR CHAR(1) NOT NULL
    , DRRACE CHAR(1) NOT NULL
    , DRSEX  CHAR(1) NOT NULL
    , DRLONG CHAR(1) NOT NULL
    , DRLGDT DECIMAL(7) NOT NULL
    , DRTYCD CHAR(4) NOT NULL
    , DRTERM CHAR(6) NOT NULL
    , DRPTAD DECIMAL(7) NOT NULL
    , DRPTAT CHAR(4) NOT NULL
    , DRHFM  DECIMAL(2) NOT NULL
    , DRSPCT CHAR(4) NOT NULL
    , DRSPST CHAR(2) NOT NULL
    , DRSDTE DECIMAL(7) NOT NULL
    , DRSTME CHAR(4) NOT NULL
    , DRPRIO CHAR(1) NOT NULL
    , DRDTED DECIMAL(7) NOT NULL
    , DRTMED CHAR(4) NOT NULL
    , DRUNTA CHAR(1) NOT NULL
    , DRUSR1 DECIMAL(7) NOT NULL
    , DRUSR2 CHAR(25) NOT NULL
    , DRUSR3 CHAR(25) NOT NULL
    , DRUSR4 CHAR(25) NOT NULL
    , DRFIL  CHAR(12) NOT NULL 
    );
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  5. #5
    Join Date
    Jun 2008
    Location
    pakistan
    Posts
    109
    r937 i agreed with you but i wanna tell you some thing that i wrote same like this but in one line and check the query that it works which i write...

  6. #6
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by don_log View Post
    r937 i agreed with you but i wanna tell you some thing that i wrote same like this but in one line and check the query that it works which i write...
    would you mind repeating the question? i don't understand what you just said
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  7. #7
    Join Date
    Jun 2008
    Location
    pakistan
    Posts
    109
    i said i write query same some thing like you,you write above dear... don't you read my reply.

  8. #8
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by don_log View Post
    don't you read my reply.
    yes, i do
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  9. #9
    Join Date
    Mar 2004
    Posts
    480
    Actually no you didn't write the same query. The back tick ` is NOT needed around column names (you've included it around all your column names and said it was necessary). The back tick is only needed when a reserved word is used or special characters are used.

    It is also not sql standard so if you ported the table creation statement over to another database it would generate an error.

  10. #10
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    Quote Originally Posted by don_log View Post
    r937 i agreed with you but i wanna tell you some thing that i wrote same like this but in one line and check the query that it works which i write...
    don_log i agreed with you but i wanna tell you some thing that r937 wrote same like you but his code is actually readable.

    Just because you CAN cram everything onto a single line doesn't mean you should. In my book, you get points deducted for that. Its called formatting and white space. Look it up.
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  11. #11
    Join Date
    Sep 2008
    Posts
    34
    Problem Solved! Thanks guys! I did not know about the single quote vs tick. Where can I find the 'tick' on a windows keyboard?

  12. #12
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by curtmorehouse View Post
    Where can I find the 'tick' on a windows keyboard?
    it's on the same key underneath the squiggle (tilde)

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

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