How to create a table in a particular database?

user295515 picture user295515 · May 1, 2010 · Viewed 89.7k times · Source

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?

Answer

Dmitry Yudakov picture Dmitry Yudakov · May 1, 2010

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, .... )