Professional Documents
Culture Documents
LAB ASSESSMENT:
Data presentation
Experimental results
Conclusion
Bachelor of Computer
Engineering Fall-22
Submitted To:
Engr. Atif bajwa
Lab Engineer
Lab Objective:
To know the working of some of the commands of SQL.
Introduction to DDL:
The DDL part of SQL permits databases and tables to be created or deleted or modified w.r.t it
Structure. It also define indexes (keys), specify links between tables, and impose constraints between
tables.
The most important DDL statements in SQL are:
• CREATE DATABASE - creates a new database
• ALTER DATABASE - modifies a database
• CREATE TABLE - creates a new table
• ALTER TABLE - modifies a table
• DROP TABLE - deletes a table
• CREATE INDEX - creates an index (search key)
• DROP INDEX - deletes an index
To delete a column in a table, use the following syntax (notice that some database
systems don't allow deleting a column):
To change the data type of a column in a table, use the following syntax:
Now we want to add a column named "DateOfBirth" in the "Persons" table. We use the
following SQL statement:
Notice that the new column, "DateOfBirth", is of type date and is going to hold a date. The data type
specifies what type of data the column can hold. For a complete reference of all the data types
available in MS Access, MySQL, and SQL Server, go to our complete Data Types reference.
The "Persons" table will now like this:
• Write an SQL statement to convert the above table into following table.
• Write SQL statement(s) to change “Birth_Date” to “Age” with data type Integer.
• Create an Index on the “Customer” table using “First_Name” and “Age”.
• Add a new attribute Supplier_Name into table.
LAB TASK 02
Consider the following table “ Product ” :
• Write an SQL statement to delete the “ProductName” entries from the table.
Output:
LAB TASK 03
Consider the following tables:
Create the above table by keeping their first columns as primary key. After the creation
of the table,
solve the following:
• Write a query to add an attribute, Class to the Student table
• Write a query to change the field for Student_Name from 25 characters to 40 characters
• Write a query to add another column in the Student table with an auto increment field
• Write a query to add another column Department in the Student table. The column
must not
contain any value other than the values COMPUTER or SOFTWARE
• Write a query to change the auto increment field to start from 50
• Write a query to remove the Student table
Code:
Output:
LEARNING OUTCOMES