creating table in mysql error

Hi,
I have to create a table with the following schema.
I am running the following code on mysql command prompt but its erroring out:
mysql> CREATE TABLE  ‘snippets' (
    '>   ‘id' char(36)  NOT NULL DEFAULT NULL
    ->   'text' text NOT NULL DEFAULT NULL,
    ->   ‘title' varchar(255) DEFAULT NULL,
    '>   'mode' varchar(255) DEFAULT NULL,
    '>  PRIMARY KEY (‘id')
    -> ) ;
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' char(36)  NOT NULL DEFAULT NULL
  'text' text NOT NULL DEFAULT NULL' at line 1

Open in new window


module.exports = [ { Field: 'id',
                     Type: 'char(36)',
                     Null: 'NO',
                     Key: 'PRI',
                   Default: null,
                     Extra: '' },
                   { Field: 'text',
                     Type: 'text',
                     Null: 'NO',
                     Key: '',
                   Default: null,
                     Extra: '' },
                   { Field: 'title',
                     Type: 'varchar(255)',
                     Null: 'NO',
                     Key: '',
                   Default: null,
                     Extra: '' },
                   { Field: 'mode',
                     Type: 'varchar(255)',
                     Null: 'NO',
                     Key: '',
                   Default: null,
                     Extra: '' } ];


/*
  +-------+--------------+------+-----+---------+
  | Field | Type         | Null | Key | Default |
  +-------+--------------+------+-----+---------+
  | id    | char(36)     | NO   | PRI | NULL    |
  | text  | text         | NO   |     | NULL    |
  | title | varchar(255) | NO   |     | NULL    |
  | mode  | varchar(255) | NO   |     | NULL    |
  +-------+--------------+------+-----+---------+
*/

Open in new window


Please let me know the correct way to do it.
Also is there a way in which i can utilize module.exports json directly to create a mysql query to create a table.

Thanks
Rohit BajajAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dave BaldwinFixer of ProblemsCommented:
You don't have a comma after '>   ‘id' char(36)  NOT NULL DEFAULT NULL .  What language is module.exports json ?
0
Rohit BajajAuthor Commented:
oh thanks for pointing that out
yes its json
0
Ryan ChongCommented:
mysql> CREATE TABLE  ‘snippets' (
    '>   ‘id' char(36)  NOT NULL DEFAULT NULL
    ->   'text' text NOT NULL DEFAULT NULL,
    ->   ‘title' varchar(255) DEFAULT NULL,
    '>   'mode' varchar(255) DEFAULT NULL,
    '>  PRIMARY KEY (‘id')
    -> ) ;
so is your fields going to be defined as NULL by default OR NOT NULL by default?

you can either try:
‘id' char(36)  NOT NULL ,
or
‘id' char(36)  NULL ,
or
‘id' char(36)  DEFAULT NULL ,
but not:
‘id' char(36)  NOT NULL DEFAULT NULL ,

and...
>>‘snippets'
pls use char ` instead to define your object's name, like:

`snippets`

instead.

Hence, you can try this instead:
CREATE TABLE  `snippets` (
`id` char(36)  NOT NULL,
 `text` text NOT NULL,
 `title` varchar(255) DEFAULT NULL,
 `mode` varchar(255) DEFAULT NULL,
 PRIMARY KEY (`id`)
 ) ;

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
MySQL Server

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.