views:

22

answers:

3

The create database statement is:

CREATE TABLE table_name ( column_name1 data_type, column_name2 data_type, column_name3 data_type, .... )

but, I'm wondering how can I create a table in a specific database?

thanks, guys!

+2  A: 

USE dbname;

http://dev.mysql.com/doc/refman/5.1/en/use.html

wRAR
I think it works, BTW is there another way to achieve this?
A: 

Assuming that you have more than one database, in mysql, you can do SHOW DATABASES to view them all and then USE with your db name to make it the current one. Running CREATE TABLE will then create the table in that database.

QuantumPete
+1  A: 

You can specify the DB Name in the same query:

CREATE TABLE database_name.table_name ( column_name1 data_type, column_name2 data_type, column_name3 data_type, .... )

Dmitry Yudakov