Create database and tables using SQL

Last updated: April 26, 2023

In relational databases, data store in table format. A database can contain multiple tables. A tables contain multiple rows. This rows are actual required information set. Table's has columns. A column's of a specific row's called Field.

So, first step is to create a database.

Syntax:  CREATE DATABASE 'name of database';

CREATE DATABASE account;

Here database name is "account".

Now, time to enter database:

use account;

Create table:

Syntax:

CREATE TABLE table_name (

    column1 datatype,

    column2 datatype,

    column3 datatype,

   ....

);

CREATE TABLE contact (
	id int,
	name varchar(255),
	age int,
	mobile varchar(255),
	address varchar(255),
	city varchar(100),
	country varchar(255)
	);

Now show all tables:

show tables;

Related post