N
20. (a) Write a Query to create a Table with the following structure:-
Table Patient
Field
PID
PNAME
DISEASE
FEES
Datatype
Char(4)
(Varchar(20)
Varchar(40)
Decimal
(b) Consider the following Book_issue table and write the queries :-
Table Book_issue
Book ID Date of Issue Student Name Returned
6001 20-01-2009 Ashish
Yes
B002 | 01-04-2015 Subhash
B008
12-05-2012 Ankita
B004 15-10-2013 Arpita
No
No
Yes
() Write a SQL Query to display all records.
(ü) Write a SQL Query to add a new row with the following details
('B005), '20-06-2014', 'Preeti', 'Yes')
(iii) Write a SQL Query to modify the Name of B003 from Ankita to
Ankur.
Answers
(a) CREATE TABLE "Patient" ( "PID" Char (4), "PNAME" Varchar (20), "DISEASE" Varchar (40), "FEES" Decimal)
(b) (i) SELECT* FROM "Book_issue"
(ii) INSERT INTO "Book_issue" ( "Book ID", "Date of Issue", "Student Name", "Returned") VALUES ('B005', '20-06-2014', 'Preeti', 'Yes')
(iii) UPDATE "Book_issue" set "Student Name"='Ankur' where "Book ID"='B003'
It is the standard interactive and programming language for retrieving and updating information from a database.
Full Form :- Structured Query Language
THE TYPES OF SQL STATEMENTS ARE BELOW :-
- SELECT statement
STRUCTURE :-
SELECT(column1,column2,column3,...)FROM table_name [WHERE condition][ORDER BY column]
- INSERT statement
STRUCTURE :-
INSERT INTO table (column1,column2,...) VALUES(value1,value2,...)
- UPDATE statement
STRUCTURE :-
UPDATE table_name SET column_name = value [,column_name = value ...] [WHERE condition]
- DELETE statement
STRUCTURE :-
DELETE FROM "table_name" [WHERE] condition
- CREATE statement
STRUCTURE :-
CREATE TABLE TABLENAME ([column definitions]) [table parameters]