How to create a table in a particular database?

Solution 1:

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

Solution 2:

USE dbname;

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

Solution 3:

You can try this query. Suppose the database name schoolmanagementsystem, table name student, and table columns name are student_id, student_first_name, and student_last_name.

So you can create a table (student) in a particular database (schoolmanagementsystem) following this way.

CREATE TABLE schoolmanagementsystem.student
(
    student_id int(10) not null,
    student_first_name varchar(20) not null,
    student_last_name varchar(20)not null
);

Solution 4:

You can create table inside a particular database as below:

CREATE TABLE database_name.table_name_();

CREATE TABLE library_database.book
(
    book_id int(10) not null,
    book_name varchar(20) not null,
    author_name varchar(20)not null
);