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

Mysql Commands

The document creates and populates multiple tables in a database called "class". It creates tables for companies, activities, students, and fees. Data is inserted into each table with multiple rows. The tables are then queried to view the inserted data. Basic SQL commands like CREATE TABLE, INSERT, SELECT, and DELETE are demonstrated.

Uploaded by

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

Mysql Commands

The document creates and populates multiple tables in a database called "class". It creates tables for companies, activities, students, and fees. Data is inserted into each table with multiple rows. The tables are then queried to view the inserted data. Basic SQL commands like CREATE TABLE, INSERT, SELECT, and DELETE are demonstrated.

Uploaded by

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

CREATE DATABASE class;

USE class;

Show tables;

#WORKSHEET 1
create table Company(
cid INT primary key,
cname varchar(6),
ho varchar(9),
contact varchar(10)
);

insert into company values(1, 'Titan', 'Okhla', 'C. B. Ajit');


insert into company values(2, 'Ajanta', 'Najafgarh', 'R. Mehta');
insert into company values(3, 'Maxima', 'Shahdara', 'B. Kohli');
insert into company values(4, 'Selko', 'Okhla', 'R. Chadha');
insert into company values(5, 'Ricoh', 'Shahdara', 'J. Kishore');

select * from company;

# WORKSHEET 2

create table Activity(


ACode INT primary key,
Event varchar(15),
Stadium varchar(15),
Number INT,
Prize INT,
SDate DATE
);

insert into activity values(1001, 'Relay 100x4', 'Star Annex', 16, 10000, '2004-01-
23');
insert into activity values(1002, 'High Jump', 'Star Annex', 10, 12000, '2003-12-
12');
insert into activity values(1003, 'Short Put', 'Super Power', 12, 8000, '2004-02-
14');
insert into activity values(1005, 'Long Jump', 'Star Annex', 12, 9000, '2004-01-
01');
insert into activity values(1008, 'Dicsus', 'Super Power', 16, 10000, '2004-01-
23');

select * from activity;

# WORKSHEET 3
create table Student(
roll INT primary key,
name varchar(10),
mobile char(10),
stream varchar(15),
avg int,
class char(3)
);

insert into student values(1, 'Karan', '9847578833', 'Biology', 79, '12B');


insert into student values(2, 'Divakar', '9961578833', 'Commerce IP', 89, '11C');
insert into student values(4, 'Arun', null, 'Biology', 73, '12C');
insert into student values(5, 'Sabina', '9446259214', 'Biology', 91, '11A');
insert into student values(6, 'Jamshed', '9345246400', 'Comp Sc', 75, '12B');
insert into student values(7, 'Sanjay', '8038594730', 'Humanities', 65, '11A');
insert into student values(8, 'Deepak', '9385753363', 'Comp Sc', 89, '12A');
insert into student values(9, 'Krishna', '9484544567', 'Comp Sc', 92, '12A');
insert into student values(10, 'Rakesh', '9754546765', 'Commerce IP', 68, '12C');

select * from student;

create table Fees(


stream varchar(15) primary key,
tution int,
sc_lab int,
comp_lab int
);

insert into fees values('Biology', 1200, 375, 0);


insert into fees values('Commerce IP', 1200, 0, 125);
insert into fees values('Commerce Math', 1200, 0, 0);
insert into fees values('Comp Sc', 1200, 250, 125);
insert into fees values('Humanities', 1200, 0, 0);

select * from fees;

## THINGS TO REMEMBER

semicolen
no comma for the last value
date as a string in yyyy-mm-dd format

CREATE TABLE student


(AdmNo INT PRIMARY KEY,
Name CHAR(20) NOT NULL,
DOB DATE,
MOBILE INT,
CLASS VARCHAR(4));

DESC STUDENT;

INSERT INTO student VALUES(1001, 'Thumbi', '2005-08-20', 987543213, '12A');


SELECT * FROM student;
DELETE FROM student WHERE AdmNo = 1002;

You might also like