0% found this document useful (0 votes)
3 views

SQL

The document outlines a series of SQL commands executed in a MariaDB environment to create a database named 'subid', along with two tables: 'supplier' and 'product'. It includes the insertion of supplier and product data, as well as various queries to retrieve and sort this data based on specific criteria. Key operations include creating foreign key relationships and performing aggregate functions on product prices.

Uploaded by

ferojwasim8
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

SQL

The document outlines a series of SQL commands executed in a MariaDB environment to create a database named 'subid', along with two tables: 'supplier' and 'product'. It includes the insertion of supplier and product data, as well as various queries to retrieve and sort this data based on specific criteria. Key operations include creating foreign key relationships and performing aggregate functions on product prices.

Uploaded by

ferojwasim8
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

# cd c:\xampp\mysql\bin

# mysql.exe -u root
MariaDB [(none)]> create database subid;
MariaDB [(none)]> use subid;
MariaDB [subid]> create table supplier(supcode varchar(3) primary key,
sname varchar(14), city varchar(14));
MariaDB [subid]> describe supplier;
MariaDB [subid]> insert into supplier values('s01','TECHNO
PARK','KOLKATA');
MariaDB [subid]> insert into supplier values('s03','COMPUTER
HEART','DELHI');
MariaDB [subid]> insert into supplier values('s02','COMPUTER
ZONE','MUMBAI');
MariaDB [subid]> select * from supplier;
MariaDB [subid]> create table product(PID int primary key, Pname
varchar(14), qty int, price int, company varchar(14),
supcode varchar(3), foreign key (supcode) references
supplier(supcode));
MariaDB [subid]> describe product;
MariaDB [subid]> insert into product
values(101,'CAMERA',120,12000,'HP','s01');
MariaDB [subid]> insert into product values(102,'DIGITAL
PAD',100,22000,'DELL','s02');
MariaDB [subid]> insert into product values(104,'PEN
DRIVE',500,1100,'LENOVO','s01');
MariaDB [subid]> insert into product values(106,'LED
SCREEN',70,28000,'ACCER','s02');
MariaDB [subid]> insert into product values(105,'GPS
SYSTEM',60,12000,'COMPAQ','s03');
MariaDB [subid]> select * from product;
MariaDB [subid]> select * from product order by Pname asc;
MariaDB [subid]> select Pname, price from product where price between
10000 and 15000;
MariaDB [subid]> select price, Pname from product where qty>100;
MariaDB [subid]> select max(price), min(price) from product;

You might also like