Professional Documents
Culture Documents
Name: Muhammad Omair Reg. No: BSCS2019-58 Computer Science (2 Year) Database Lab Report
Name: Muhammad Omair Reg. No: BSCS2019-58 Computer Science (2 Year) Database Lab Report
First of all open MySQL 8.0 Command Line Client. Enter your password.
Now the data is created. To check whether database is created or not, type “show databases;”
Now I have to insert the data. To insert the data, I used the query ‘INSERT INTO [table-
name]’ and ‘VALUES’ to insert values into the table. After that, I wrote a query, ‘SELECT *
FROM CUSTOMER’ to show all the data present in table. After all these queries, my table
looks like this.
Now here, I add another column of ‘ID_card’. The data to put in the ‘ID_card’ column will be
as integer. I used the query ‘ALTER TABLE [table name]’ to alter the table and add the
column as ‘ADD ID_card int’. After that, I added two customers’ data with ID_card using
‘INSERT INTO’ function.
After that, I write query to show the customer's name, ID_card, and his country. The query is
‘select CustomerName, ID_card, Country from CUSTOMER’. This query will only shows
the data of specific columns. You can see it as follow.
Using this query, I deleted the column “ID_card”. The query is “ALTER TABLE
CUSTOMER DROP COLUMN ID_card;”. You can clearly see in the following picture, the
ID_card column is deleted.
By using the query “TRUNICATE [table name]”, all the data in table has been deleted. You
can see it as follow:
By using a query “DROP TABLE [table name]”, this will delete the customer table as shown in
the following.
And at last, by using a query “DROP DATABASE testdb”, the database will be deleted.