PRACTICAL NO-3 Study of DDL and DML Command. Create Table and Insert Sample
PRACTICAL NO-3 Study of DDL and DML Command. Create Table and Insert Sample
Aim: Study of DDL and DML command. Create table and insert sample data in
tables.
SQL Important Commands
Here is the list of some important SQL Commands:
Commands Descriptions
CREATE VIEW Creates a virtual table based on the result of a SQL statement.
INSERT INTO SELECT Inserts data from one table into another based on a query.
Commands Descriptions
Removes all records from a table, but keeps the table structure
TRUNCATE TABLE
intact.
SQL CREATE TABLE Statement is used to create a new table in a database. Users can define the
table structure by specifying the column’s name and data type in the CREATE TABLE command.
This statement also allows to create table with constraints, that define the rules for the table. Users
can create tables in SQL and insert data at the time of table creation.
Syntax
To create a table in SQL, use this CREATE TABLE syntax:
In this example, we will create table in SQL with primary key, named “EMPLOYEE”.
Let us create a table to store data of Customers, so the table name is Customer, Columns are
Name, Country, age, phone, and so on.
Output:
To add data to the table, we use INSERT INTO command, the syntax is as shown below:
Syntax:
Output: