0% found this document useful (0 votes)
4 views12 pages

SQL ASSIGMENT - Copy

The document provides an overview of SQL, including its components such as Data Definition Language, Data Manipulation Language, and Transaction Control Language. It outlines various SQL commands for creating, altering, and managing tables, as well as performing data manipulation tasks. Additionally, it includes assignments focused on practical SQL applications, such as inserting data, selecting queries, and utilizing constraints.

Uploaded by

kunal Arora
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)
4 views12 pages

SQL ASSIGMENT - Copy

The document provides an overview of SQL, including its components such as Data Definition Language, Data Manipulation Language, and Transaction Control Language. It outlines various SQL commands for creating, altering, and managing tables, as well as performing data manipulation tasks. Additionally, it includes assignments focused on practical SQL applications, such as inserting data, selecting queries, and utilizing constraints.

Uploaded by

kunal Arora
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/ 12

SQL

(Structured Query Language)


SQL

DATA DEFINATION LANGUAGE


 Create table
 Alter table
 Drop table

DATA MANIPULATION LANGUAGE


 Insert into
 Delete
 Update
 Select

TRANSACTION CONTROL LANGUAGE


 Commit
 Rollback
 Set Transaction

Sample Tables
Empl table
Dept table

Pet Table

Event Table

Student Table
Assignment-1
Basic SQL Commands
P.1 Show databases

P.2 Open database


Use menagerie;
Output:
P.3 Show tables
P.4 Source command:
Use notepad and write the SQL command and save with .sql extession.
mysql> source d://ABSSS.sql;
P.5 Structure of table .
Mysql > desc ABSSS;
P.6 Structure of empl table.

DDL Commands
Assignment-2
Creating Table with different constraints:
 Not null
 Unique constraint
 Primary key constraint
 Default constraint
 Check constraint
Table – employee
(a).Create table with unique constraints:

(b).Create table with Primary key constraints:

(c).Create table with default key constraints:


(d).Create table with check constraints:

Assignment-3
Table constraint and Column constraint
(a) Table constraint

(b) Column constraint

Assignment-4
Alter Table Command.
(a) Adding Columns:

(b) Modify Column Definitions


 Datatype
 Size
 Default
 Column constraint
(c) Changing a Column Name:

(d) Changing a Table’s Name

(e) Drop table commands:


 Drop primary key

 Drop DNAME column from DEPT table

DML Commands
Assignment-1
(a) Inserting Data in Tables:
Insert into command with Null

Insert into command with date

Assignment-2
The SELECT Command
(a) Selecting all columns
(b) Reordering Columns in query

(a) With keyword DISTINCT

(b) All keyword

(c) Perform simple calculations


(d) Scalar Expressions

(e) Using column Aliases

(f) Handling Nulls pg 321, 322

(g) Putting Text in the Query output000000


(a) Use of relational operator

(b) Eliminating Redundant Data(with keyword DISTINCT)


Program:
(c) Electing from all the rows – All keyword
Program:

(d) How to Perform Simple calculation?


Program:

(e) Using Column Aliases.


Program:

(f) Handling Nulls


Program:
(g) Putting Text in the Query Output
Program:

(h) Relational Operators:

(i) Logical Operators:

(j) Searching for NULL:


(k) ORDER BY clause:

(l) CONDITION BASED ON A RANGE:

(M) CONDITION BASED ON A LIST

(N) Condition Based on Pattern Matches


1. To list members which are in areas with pin codes starting with 13,the command is:

2. To list names of pet who have names ending with ‘y’, the command would be:
3. To list members which are not in areas with pin codes starting with 13, the command is:

Assignment-3
Consider the following MOVIE database and answer the SQL queries based on it.
(a) Retrieve movies information without mentioning their column names.

(b) List business done by movies showing only MovieID ,MovieName and BuisnessCost.

(c) List the different categories of movies.

(d) Find the net profit of each movie showing its ID ,Name and Net Profit.

(e) List all movies with ProductionCost greater than 80,000 and less than 1,25,000 showing ID,
Name and ProductionCost.

(f) List all movies which fall in the category of Comedy or Action.

(g) List the movies which have not been released yet.

You might also like