0% found this document useful (0 votes)
15 views8 pages

Co1 SQL

The document outlines SQL commands for creating and modifying database tables related to tournaments, matches, players, books, and articles. It includes instructions for defining table structures, adding columns, modifying data types, and implementing constraints. Additionally, it describes various operations such as inserting data and renaming columns within the database schema.

Uploaded by

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

Co1 SQL

The document outlines SQL commands for creating and modifying database tables related to tournaments, matches, players, books, and articles. It includes instructions for defining table structures, adding columns, modifying data types, and implementing constraints. Additionally, it describes various operations such as inserting data and renaming columns within the database schema.

Uploaded by

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

quey assignmnt S Rom

h) Guate the
tonament talee as her nomation belous
CREATE TABLE Townnint(
INTEGER PRIMARY KEY,
TNane VARCHAR2 C30) NOT
NULL,
Startot DAT E NoT

nddt DATE
INTEGER NOT

5) Sneks att has oanis


comany tonaments am
Mwltine indiaual srots and iwtd ton rankuol
tiayoes te niay. ach tonamint cemyuses multnle
kneok ut kemat aeh moteh is nlayiod

CRE ATE TABLE


tlayerl
PId INTEGER RIARY KEY,
PNane VARCHAR 2(20 NOT NÚLL,

karing INTEGER NOT NULL

2)a) ieate mateh taiee as nLY Ntiis low-, Aplay came


ims so niaue shoulod not be
equal te iayer 2
Co3 Assinyment

TABLE Match C
CREATE
PRLMARY KEY,
MId INTEG ER
NOT NULLy
TId INTEGER
NULL,
Mar INTEGIER NOT
NULL,
llayer 2 INTEG ER NOT
Matehbt DATE NOT NULL)

winn INTE GERJ


Scoe VARCHAR 2 (30) NoT NULL

Matehelayol NUMBERJ
MatoheWon NUMBER,
FoRE IGN KEY (TId) REFERENCES TouUnament (Trd),

FORE IGN KEY (Reayur) REFER EVCES luy( Prd),


FoRE IGN KEY(Ra 2) REFERENCES Player CPTo),
FORE IGN KEY (Wimer) REFE RENCES Rlaye (PTd
CHECK Clay<> layr)

Add ' Matohes tlayol ,'Matehswen' oewmn o kyne


wunBER Ao
Mateh kalble
ALTER TABLE Mateh
ADD MatehesPioyeol NU MBER)
ALTER TABLE Mateh
AbD MatohesWem NUMBER

Rex, a isaian woants te autemate tlh


bot
bansactiens (boaun ano aetuing)in his ibrany.
Hee the stucte Anal ues fo the loo
tabt
khat has beem desiqnus
chaact and stats oith B

enol 20
KThe name ot he authot doe nut
ohacs

to be cuatea to Mou he dtoson


A tas has
of the tabte as Rer's
yeu heln oith the ouation
Preqihunt
CREATE TABLE Book (

BookId CHARC6) PRIMARY KEY CHECk (BootTd LIKE B)


Wtle ARCHAR2 (So) NOT NULL)
Author VARCHAR2 (20) NOT NULL,
Ghene VARCHAR2 (1o) CHECk (Gene tNC'Mye Trlla)
Yearef uwiatm TNTEGER NOT NULL

Mediy the sunlin tatle te stwe the snun city.The


oumn mome shou be ty and it can haue maimum

ALTER TABLE Snlier


ADD Cty VARCHAR2 (10)

Maduy datatyn o Wame to VARCHAR2 Cso) in Bayr Tate.


ATER TABLE louy
MODIFY PName VARCHAR2 (50)
DDon cHumn'iomtact No' em tabte Playen
ALTER TABLE Playen
MQDTEY DROP cOLU MN ontactNo;
) Remam oomn pID' to Playo Td im kable player
|ALTER TABLE Rlay
RENAM E COLUNMN PId to layotd
d) Add Calumn 'matheswen' of kyne NUmBER Ln tabte

ALTER
TABLE Rlaye
ADD Malcheswen NUMeER
5) a) Guate the shonn dalle with aeriate sata tyrus
kor the attibwtes desoibed belos
CREATE TABLE shennerC

ShanId INTEGER PRIMARY KEY,


ShowName VARCHAR 2(20) NoT NULL,
Gend CHARC) CHECK (nenoer INCm', F))*
Moie VARCHAR2 Ci5),
Addsuss VARCHAR2 (ioo

5) Aller kaite shann te change the data


ynu ot
meile ume om NäMBER te VARCHA R2Mae
Mwumr an have a maciwm nath ot l5 charactos
ALTER TABLE Sherne
MODTF Y Molile VARCHAR2 (15),
ALTER TASLE Shonrn
RENAME COLUMN M a o T0 / s

CREATE TABLE EmPC


EMENM
pRIMARY YY CHEK
EMP. NrM CHAR(3)

07 NVL,
EMP_ LN AME VARCHAR2 C15)
NO7 VL,
EMP.FNAME VARCHAR 2Ci5)
EETWEEN
CHARC) CHECK CEMP-2IT IA L
EMP_ INITIAL
IA' AND z')

EMp-HIRE DATE o ATE NOT NVLLy


NVLL,
Joß-CoDE VARC HAR2 (10) NOT
JOS(306-ID)
kEY CJoB-coDE) REFE KENCES
FORE IGN

CREATE TAGLE JOBC


PRTmARY KEY,
JoB-ID VARCHAR2 (Io)
L,
TLTLE VARCHAR2 (I5) NOT AUL
JO8-
JULL,
SALARy NUMBER () NOT
MIN-
NULL.
NUMEER C6) NOT
MAX-SAL ARY

to aool coumn STARS


tatetement
wute a sa L
ARCHAR 2(5)) to the tabe JoB
(V
ALTER TABLE JOB
Ra (s)
ADD STARS VARC H A
Ohvn.thaintnomm,corthoint. yn,Aabe nana
Cashainta

pROP TABLE EMP


DROP TAB LE OB,

1)oGuate the Atica table as ne syuelication below


CREATE TABLE Aial

Aeede CHARCS) PRIMARY KEY cHECK(AX Cooe LIkE 'A.'),


Aname VARCHARC32 0) NOT NULLy
Rate nUMBER (s,2),
6uantity NUMsER) DEFAULT O CHECK CQuatity >o),
Class cHARCO CHECK CCaoas INCA', B','c))

() Tnst the follouing data imte Ankicla Tausd.


TNSERT INTO Artielel Aesda, Anam, Rate, Quantity, Class)
VALUES CA100,'Mowse', So0, 0,'C))
(ii) Moolity the Arcooe cumnAioth to to.
ALTEK TABLE Articl MoDrFY Asd CHARlio),

(i) Adol a ooumn'A ISBM" ih the datatyne achar (1)


then unolate the Vae to the o you hae
anal
iwted i t h Akoroe as"A100"
ALTER TABLE Artiee ADD A ISGN VAR CH AR (2 o),
urpATE Aticl SE T AISBN=SomwValue' wHERE
A o : 'Aloo
V)Dn the cansthaint asiqnid to quantity atlitute
ALTER TABLE Aticu DROP ONSTRAINT hk- quantaty

CREATE TABLE Bilc

BiiNo NäMBER PAIMARY KE Y,


Ste Name VARCHAR (20) FoRE TGN kEYREFERENCES
Stoe (StoreNami),
Sheyurid NUMBR FORETGN KEy REFERENCES
Shopper Csherrd),
Acsole CHAR (S) FORErGN

|leouty the iill sot tabe to stoe the Bie Tas. The
comn mame shod e tarc and the data
|tyre sheuio be an mmbe.
ALTER TABIE Bl ADD Tax Numlr

c) Renanne conmn 'Ameunt' te Bll Amount n BilU


kabee
ALTER TABLE Bii RENAME COLUMN Annount TO BilAmeunt
a) Ute a SaL statmnt to cony th content of th
ab ca taii
inte the muo tall Cardtars.
CREAT E TABLE Car- Details AS SELECT * FROM
Car
b) Wike a se quey te conyony thu
Car- dilaris
CREATE TAGLE Ca-detailsi AS SELECT * FROM Cas
WHERE (arolo Black';
c) Rename coumn 'ar Colo to' color in car tale.
ALTER TASLE Car RENAME COLUMN Car
cols To Color,
d)|Meoiky the Car Nam Width to 25 im car kalee
|ALTER TABLE Ca moDIFY CorName
VARCHAR (25);
1o) )Add nqne constaint ke hitle in boetes taile
ALTER TABLE books ADD CONSTRA TNT wnigue- tite

2) Ado not ll
UNIQUECtikl);
constaint he nice ¢m books talle
ALTER TABLE books MODTFYy °e FLOAT
NOTNULL)
)ALTER bhe NoT NULL comsthaint An khe we celuumn
and et a chuek cesaint to enu he Vaua s
qteat than o.04.
|ALTER TABLE boots MoDTFY ce FLOAT WOT NULL)
ALTER TAB LE books ADD CONSTRATNT ehck.ouee CHECK(PPe 7004);
d) DROP THE NoT NOLL enstint to the aty coumn dm
the boets table

ALTER TABLE books MoDIFY aty TNT NULL:


booky tabee
e) set a delault Aaueo Aty to o in thu
DEEAAULT O
ALTER TABLE books MoDIEY Aty INT

You might also like