Thomas’ Developer Blog

March 23, 2008

Creating table in mysql

Filed under: sql — Tags: , , , , , , — sanzon @ 1:33 am

This is just something that annoys me at times.  In mysql you can typically type:

Show create table TableName, and it will show you the code to create that table.

Probably is they use single quotes which won’t work if you type in that code.  So to actually give people a real working version of the create table version, here ya go:

Create TABLE users (
User_ID int(11) NOT NULL auto_increment,
Name varchar(60) NOT NULL,
CreatedOn TIMESTAMP default NOW(),
About Text,
Video_ID int(20),
Primary Key (User_ID),
Unique Key (Name),
Constraint users_ibfk_1 Foreign Key (Video_ID) references video (Video_ID) on Delete Set NULL
) ENGINE=InnoDB Default CharSet=utf8;

Well hopefully that helps.  Basically… you don’t use the single quotes at all!  Anyway, that’s just a general example, and not that I do highly HIGHLY recommend using UTF8 ALWAYS for databases.  Never know when you’ll need unicode support in the future.

Advertisements

1 Comment »

  1. Hello there! Would you mind if I share your blog with my facebook
    group? There’s a lot of people that I think would really enjoy your content. Please let me know. Many thanks

    Comment by sms forex signals — May 5, 2013 @ 5:15 am


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: