Chương 4. Ngôn ngữ SQL
SQL- Strutured Query Language
DDL: Data Definition Language
(Ngôn ngữ tạo dữ liệu)
DML: Data Manipulation Language
(Ngôn ngữ thao tác dữ liệu)
DCL: Data Control Language
(Ngôn ngữ điều khiển dữ liệu)
Cho CSDL quản lý bán hàng
Hang(mahang, tenhang, dvt)
Hoadon(mahd, ngayhd, makh)
Chitiet(mahd, mahang, soluong, dongia)
Câu lệnh tạo bảng Hang
Create table hang
(mahang text primary key,
Tenhang text(30),
Dvt text)
Create table chitiet
(mahd text references hoadon(mahd),
Mahang text references hang(mahang),
Soluong integer,
Dongia single,
Primary key (mahd, mahang))
Alter table hang add column ngaysx datetime, noisx text
Alter table hang drop column noisx
Alter table chitiet alter column dongia double
insert into hang values
(‘h01’, ‘hoa hong’, ‘bo’)
Insert into hoadon(mahd, makh)
Values (“hd01”, “kh01”)
Insert into chitiet values
(‘hd01’, ‘h01’, 30, 3500)
Vd1. Update hang set dvt=’cai’ where mahang=’h01’
Vd2. Update chitiet set dongia=dongia+2000
Where mahang=’h01’ or mahang=’h01’
Vd3. Update hoadon set ngayhd=date()
Delete from hang where tenhang like “hoa*”
Delete * from chitiet
Cho CSDL quản lý điểm. Viết câu lệnh thực hiện các yêu cầu sau
Monhoc(mamh, tenmh, sotc)
Sinhvien(masv, hoten, phai, ngaysinh)
Thi(masv, mamh, ngaythi, diem, ketqua)
» Tin mới nhất:
» Các tin khác: