You are on page 1of 8

Assignment-22

Create a table student_Marks with the following fields

S_NO

Name

Marks

Enter 10 records in the table and execute the following queries

I. Display S_No. of those students whose name start with L and ends with A and Marks <70.
II. Display the name and S.NO of those students who have scored marks=95.
III. Display the names and marks of all the students who have scored marks between 75 and 90
Assignment-23( maam ne whatsapp mai bheja hai as 20)

Write SQL Quiers using data manipulation command, Insert records into table Named Employee
ASSIGNMENT-24
Q1 Discuss all the DDL commands with their syntax.

Solution: DDL or Data Definition Language actually consists of the SQL commands that can be
used to define the database schema. It simply deals with descriptions of the database schema and
is used to create and modify the structure of database objects in the database. DDL is a set of
SQL commands used to create, modify, and delete database structures but not data. These
commands are normally not used by a general user, who should be accessing the database via an
application.

DDL Commands are-

1. CREATE TABLE:

Definition: "CREATE TABLE" is an SQL command that creates a new database table. It
specifies the table's structure by defining columns and their data types. You can also set
constraints, such as primary keys. This command establishes a blank canvas for storing data
in an organized manner.

Syntax: CREATE TABLE table_name (

column1 datatype,

column2 datatype,

...

);

Example: CREATE TABLE employees (

employee_id NUMBER(3),

first_name VARCHAR(50),

last_name VARCHAR(50),

);

2. ALTER TABLE:

Definition: "ALTER TABLE" is an SQL command used to modify an existing table's


structure. It enables you to add, modify, or delete columns, change data types, and impose
constraints like primary keys. This command allows for flexibility in adapting tables to
evolving data requirements.
Syntax: ALTER TABLE table_name

ADD column_name datatype;

Example: ALTER TABLE employees

ADD email VARCHAR(100);

3. TRUNCATE TABLE:

Definition: "TRUNCATE TABLE" is an SQL command that swiftly removes all rows from
an existing table while preserving its structure. It is a non-reversible operation, commonly
employed to reset a table to an empty state, erasing existing data.

Syntax: TRUNCATE TABLE table_name;

Example: TRUNCATE TABLE employees;

4. DROP TABLE:

Definition: "DROP TABLE" is an SQL command employed to permanently delete an entire


database table, including its data and structure. It is a decisive action, and caution is essential
as the data cannot be recovered once the table is dropped. This command is useful for
eliminating unnecessary or obsolete tables from a database.

Syntax: DROP TABLE table_name;

Example: DROP TABLE employees;


ASSIGNMENT-25
Q1 Discuss all the DML commands with their syntax.
ASSIGNMENT-26
Q1. Write SQL queries using DDL commands like create, DROP, ALTER and DML commands
like INSERT and DELETE.

You might also like