0% found this document useful (0 votes)
28 views10 pages

SQL Practice

Structural query language examples

Uploaded by

thelegendone333
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views10 pages

SQL Practice

Structural query language examples

Uploaded by

thelegendone333
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

*Creating a Table

‘DateSheet’*
CREATE TABLE DateSheet
(
Course_Code varchar,
Subject Varchar,
Day varchar,
Date,
Time
);

*Inserting enteries into


the Table*
INSERT INTO DateSheet
(Course_Code, Subject, Day, Date, Time)
VALUES ('CMP-370', 'Database System',
'Thursday', '17-06-2021', '09:00-11:00 am');
*Inserting multiple
enteries into the table*
INSERT INTO DateSheet
(Course_Code, Subject, Day, Date, Time)
VALUES ('SS-471', 'Research Methods', 'Monday',
'14-06-2021', '12:00-02:00 pm');
INSERT INTO DateSheet
(Course_Code, Subject, Day, Date, Time)
VALUES ('CMP-223', 'COAL', 'Tuesday', '15-06-
2021', '09:00-11:00 am');
INSERT INTO DateSheet
(Course_Code, Subject, Day, Date, Time)
VALUES ('CS-312', 'Analysis of Algorithm',
'Wednesday', '16-06-2021', '09:00-11:00 am');
INSERT INTO DateSheet
(Course_Code, Subject, Day, Date, Time)
VALUES ('CMP-370', 'Database System',
'Thursday', '17-06-2021', '09:00-11:00 am');
INSERT INTO DateSheet
(Course_Code, Subject, Day, Date, Time)
VALUES ('CS-324', 'Compiler Construction',
'Friday', '18-06-2021', '09:00-11:00 am');
*Creating Table using
another Table*
CREATE TABLE Examination_Schedule AS
SELECT * FROM DateSheet;

*Inserting all columns


of a table into a new
Table*
INSERT INTO DateSheet
SELECT * FROM Viva_DateSheet;

*SELECT Statement*
SELECT subject, Date, Time FROM
Examination_Schedule;
SELECT * FROM Examination_Schedule;

SELECT DISTINCT time FROM


Examination_Schedule;
*WHERE Clause*
SELECT * FROM Examination_Schedule
WHERE time='09:00-11:00 am';

*ORDER BY
Keyword*
SELECT * FROM Examination_Schedule
ORDER BY date ASC;
*UPDATE Statement*
UPDATE Examination_Schedule
SET TIME='09:00-11:00 am'
WHERE subject= 'Research Methods';
*DELETE Statement*
DELETE FROM Examination_Schedule
WHERE subject='Compiler Construction';

DROP TABLE Examination_Schedule;

NAME: ALI HASSAN


ROLL NO: BSCS-F19-M49

You might also like