3. How to Create a Database, a Table, and Insert some data using SQL?

preview_player
Показать описание
Create a Database using SQL Data Definition Language Command "Create", Use the Database, Create a Table in that Database, and Insert a Record in the Table using Data Manipulation Language Command "Insert Into" . Insert multiple Records into the Table and verify the Table Records with "Select" Command.
Using SQL Commands we can create Databases, Tables, and Insert data into Tables...

SQL Commands can be divided in to 4 categories,
1. Data Definition Language
2. Data Manipulation Language
3. Data Control Language
4. Transaction Control Language

Step 1: Create a Database
It is Data Definition Language Operation.

Syntax:
Create Database Database_Name;

Example:
Create Database gcreddy;
-----------------------------------
Step 2: Create a Table in the Database
It is also Data Definition Language Operation.

Before Create a table first Use/Select database...

Syntax:
CREATE TABLE table_name (
column1 datatype,
column2 datatype,
column3 datatype,
....
.;

Example:
Create Table abcd(
Id int,
Name varchar (50)
);
-----------------------------------
Step 3: Insert a Record in to the Table
It is Data Manipulation Language Operation.

Syntax:
Insert Into table_Name (column1, column2, colum3....)
Values (Value1, Value2, Value3...);

Example:
Insert Into abcd
(Id, Name)
Values (1, 'Ramesh');

Select * From abcd;
-----------------------------------
Step 4: Insert multiple Records...

Example:
Insert Into abcd
(Id, Name)
Values (2, 'Venkat'),
(3, 'Ramu'),
(4, 'Bhasha'),
(5, 'David')
;
-----------------------------------
Step 5: Check the Table using Select statement...

Syntax:
Select * From table_Name;

Example:
Select * From abcd;

Database Table with Records...

Example:
Insert Into abcd
(Id, Name)
Values (2, 'Venkat'),
(3, 'Ramu'),
(4, 'Bhasha'),
(5, 'David')
;
-----------------------------------
Рекомендации по теме
join shbcf.ru