-- ------------------- STUDENT: Tùng Huynh
-- ------------------- CLASS: K7A
-- ------------------- Lesson 2.
-- Cau I: (Session -> New Session: SYSTEM)
-- Tạo user và grant quyền
create user may12tunghuynh IDENTIFIED by 12345;
grant CONNECT to may12tunghuynh;
grant RESOURCE to may12tunghuynh;
grant create view to may12tunghuynh;
-- Câu II.
-- Tạo bảng tb_sanpham
create table tb_sanpham(
id number not null,
ten_spham VARCHAR2(500),
so_luong NUMBER,
ngay_nhap_kho date,
id_noi_sxuat number,
id_nvien_nhapkho NUMBER,
gianhap_1spham float(10),
giabantoithieu float(10) )
-- Tạo bảng tb_noisxuat
create table tb_noisxuat(
id number not null,
noi_sxuat varchar2(500) )
-- Tạo bảng tb_nhanvien
create table tb_nhanvien(
id number not null,
ten_nvien varchar2(300),
ngaysinh date,
noisinh varchar2(1000),
gioi varchar2(10),
ngayvaolam date,
ngyanghiviec date)
-- Tạo bảng tb_spham_ban
create table tb_spham_ban(
id number not null,
id_spham_ban number,
id_nvien_ban number,
soluong number,
ngayban date,
giaban float(10) )
-- II.1.
-- Tạo khóa chính cho 4 bảng trên
alter table tb_spham_ban
add CONSTRAINT pk_sp_ban PRIMARY key (id)
alter table tb_sanpham
add CONSTRAINTS pk_sp primary key (id)
alter table tb_nhanvien
add constraint pk_nvien PRIMARY key (id)
alter table tb_noisxuat
add constraint pk_noisx PRIMARY key (id)
-- alter table tb_noisxuat
ΔΙΑΒΑΖΕΙΣ
Bài thực hành Oracle (4 tuần) - Tunghuynh_bai1
ΤυχαίοTổng hợp các bài tập Oracle (PL/SQL) cơ bản - by Tùng Huynh