0% found this document useful (0 votes)
23 views5 pages

Ex. No: 5 Date:: Displaying Team and Match - Details Table Aim

The document outlines the creation of a 'Sports' database with two tables: 'TEAM' and 'MATCH_DETAILS'. It details the structure and constraints of the 'TEAM' table, including inserting four teams, and specifies the creation and insertion of match details in the 'MATCH_DETAILS' table. Additionally, it includes SQL queries for manipulating a 'PRODUCTS' table, such as inserting, updating, deleting records, and altering the table structure.

Uploaded by

kingslynf
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)
23 views5 pages

Ex. No: 5 Date:: Displaying Team and Match - Details Table Aim

The document outlines the creation of a 'Sports' database with two tables: 'TEAM' and 'MATCH_DETAILS'. It details the structure and constraints of the 'TEAM' table, including inserting four teams, and specifies the creation and insertion of match details in the 'MATCH_DETAILS' table. Additionally, it includes SQL queries for manipulating a 'PRODUCTS' table, such as inserting, updating, deleting records, and altering the table structure.

Uploaded by

kingslynf
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/ 5

EX.

NO : 5
DATE :
DISPLAYING TEAM AND MATCH_DETAILS TABLE

AIM:

 Create a database “Sports”.

 Create a table “TEAM” with following considerations:


o It should have a column TeamID for storing an integer value
between 1 to 9, which refers to unique identification of a
team.
o Each TeamID should have its associated name
(TeamName), which should be a string of length not less
than 10 characters.
o Using table level constraint, make TeamID as the primary
key.
o Show the structure of the table TEAM using a SQL
statement.
o As per the preferences of the students four teams were
formed as given below. Insert these four rows in TEAM table:
 Row 1: (1, Tehlka)
 Row 2: (2, Toofan)
 Row 3: (3, Aandhi)
 Row 4: (4, Shailab)
o Show the contents of the table TEAM using a DML
statement.
 Now create another table MATCH_DETAILS and insert data.
Choose appropriate data types and constraints for each attribute.

QUERIES:
1. Create a database “Sports”.
Mysql> create database Sports;
Mysql> use Sports;
2. Creating table “Team” with the given specification.
Mysql> create table team (teamid int(1), teamname varchar(10),
primary key( teamid ));
3. Showing the structure of table using SQL statement:
Mysql> desc team;
4. Inserting the values into the team table.
Mysql> insert into team values(1,’Tehlka’);
Mysql> insert into team values(2,’Toofan’);
Mysql> insert into team values(3,’Anandhi’);
Mysql> insert into team values(4,’Shailab’);
5. Display the details of table – team.
Mysql> select * from team;
6. Creating another table match_details with appropriate
datatypes and constraints.
create table match_details (matchid varchar(2) primary key,
matchdate date, firstteamid int(1) references team(teamid),
secondteamid int(1) references team(teamid), firstteamscore int(3),
secondteamscore int(3));
7. Inserting the values into the match_details table.
Mysql> insert into match_details values(‘M1’,’2023-12-
20’,1,2,107,93);
Mysql> insert into match_details values(‘M2’,’2023-12-
21’,1,2,107,93);
Mysql> insert into match_details values(‘M3’,’2023-12-
22’,1,2,107,93);
Mysql> insert into match_details values(‘M4’,’2023-12-
23’,1,2,107,93);
Mysql> insert into match_details values(‘M5’,’2023-12-
24’,1,2,107,93);
Mysql> insert into match_details values(‘M6’,’2023-12-
25’,1,2,107,93);
8. Display the details of table match_details
Mysql> select * from match_details;

RESULT:
The above SQL queries have been executed successfully and the output
is verified.
EX. NO :6
DATE :
DDL & DML COMMANDS USING PRODUCTS TABLE
AIM :
Write SQL queries based on the Products table.

QUERIES:
(i) Insert a new record in the table having following values:
[1002,’Punching Machine Medium’,150,2000,’2018-04-03’]
insert into products values(1002,’Punching Machine
Medium’,150,2000,’2018-04-03’]
(ii) To change the value NULL to 250 in quantity column.
Update products set qty=250 where code=1009;
(iii) To remove the records of those products whose prices are less
than 2000 .
delete from products where price<2000;
(iv) To add a new column ‘BRAND’ of suitable data type.
Alter table products add brand varchar(30);
(v) To display the products table whose item name contains
character ‘n’.
select * from products where item like ‘%n%’;
RESULT:
The above SQL queries have been executed successfully and the output
is verified.

You might also like