Create Table in MYSQL by R4R Team

For creating any table of database we require the following things:
1.Table name
2.Attributes(columns) name of table
3.Data type of columns

How Create a Table?

Syntax:
CREATE TABLE table_name(column_name column_type ....)

How we create a Database 'Library' which contain two tables
-Student table
-Librarian table

SHOW DATABASE;


Database
employee
student
library
shopping


Now we select library database to create a table:

USE library

output:

Database changed


Now we finally Create a table:

CREATE TABLE student(id int primary key, name varchar[20], book_id int )

-In this query, we create the student table.

CREATE TABLE librarian(id int primary key,librarian_name varchar[20],book_id int )

-In this query, we create the librarian database.

To see the existing table we use following Query:

SELECT * FROM student;

id name book_id

SELECT * FROM librarian;

id librarian_name book_id



Leave a Comment: