0% found this document useful (0 votes)
2 views3 pages

SQL

The document contains SQL queries for creating and manipulating a database named 'store' and a table 'orderDemo' with various columns. It includes commands to create, copy, delete tables, and insert records into 'orderDetail' and 'employee' tables. Additionally, it provides queries to display records and unique salaries from the employee table.

Uploaded by

hemabhooshithal
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)
2 views3 pages

SQL

The document contains SQL queries for creating and manipulating a database named 'store' and a table 'orderDemo' with various columns. It includes commands to create, copy, delete tables, and insert records into 'orderDetail' and 'employee' tables. Additionally, it provides queries to display records and unique salaries from the employee table.

Uploaded by

hemabhooshithal
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/ 3

Q1) Write a query to create a database named “store”.

CREATE DATABASE store;

Q2) Write a query to create a table in ‘store’ Database with name “orderDemo” which will have 5
columns

i. id (Integer ,Primary key)

ii. Product name (String, Not Null)

iii. Order date (Date)

iv. Price (Decimal, Not Null) v. Quantity (Integer)

USE store;

CREATE TABLE orderDemo(

id int PRIMARY KEY,

product_name varchar(50) NOT NULL,

order_date date,

price decimal(10,2) NOT NULL,

quantity int );

Q3) Write a query to create a new table named “orderDetail” which is the exact copy of “orderDemo”
Table.

CREATE TABLE orderDetail AS SELECT * from orderDemo;

Q4) Write a query to delete the “orderDemo” table.

DROP TABLE orderDemo;

Q5) Insert one record in “orderDetail” table.

INSERT INTO orderDetail VALUES (1,'pen','2023-01-01',9.05,3);

Q6) Insert minimum 5 records at once in “orderDetail” table. (As per your choice)

INSERT INTO orderDetail VALUES

(2,'Book','2023-01-01',520,2),

(3,'Ink','2023-01-12',50.55,1),

(4,'Map','2023-01-19',25,5),

(5,'Bottle','2023-01-30',600,1),

(6,'Marker','2023-02-05',80,4);
Q 7) Insert 2 records only into id, Product name and Price column.

INSERT INTO orderDetail (id, product_name, price) VALUES

(7,'pen',65.90), (8,'Tape',10);

Q8) ) Write a query to create a table employee

CREATE TABLE employee(

id int PRIMARY KEY,

name varchar(50) NOT NULL,

salary int,

department varchar(50),

dob date );

Q9) ) Insert minimum 10 records at once in employee Table.

INSERT INTO employee VALUES

(101,'Jack',2000,'HR','1997-05-19’),

(102,'Jack',NULL,'HR',NULL),

(103,'Mack',6000,'Developer','1997-03-10’),

(104,'Peter',4000,'Tester','1998-07-16’),

(105,'Tom',3000,'HR','1998-11-03’),

(106,'Leo',2500,'Developer','1997-10-10’),

(107,'Roger',5300,'Accounts','1997-06-17’),

(108,'Mike',2000,NULL,'1998-03-09’),

(109,'Paul',4800,'Developer','1998-12-28’),

(110,'Hannah',2000,'Accounts','1999-09-26');

Q8) Write a query to display all the records of employee Table.

SELECT * FROM employee ;

Q10) Write a query to display unique salary of employee table.

SELECT DISTINCT salary FROM employee;

Q11) Write a query to display all data of name and dob column of employee table.

SELECT name, dob FROM employee;


Q11) Write a query to display Id , name and the annual salary with the column name 'annual_salary'
from the employee table.

SELECT id, name, salary*12 AS annual_salary FROM employee;

You might also like