FIT9132 Tutorial 7 Sample Solution
FIT9132 Tutorial 7 Sample Solution
txt
set echo on
-- 7.1
-- DDL for Student-Unit-Enrolment model
-- Place DROP commands at head of schema file
-- Create Tables
-- Here using both table and column constraints
--
create table student (
stu_nbr number(8) not null,
stu_lname varchar2(50) not null,
stu_fname varchar2(50) not null,
stu_dob date not null,
constraint pk_student primary key (stu_nbr),
constraint ck_stu_nbr check (stu_nbr > 10000000));
-- 7.1
-- DDL for Student-Unit-Enrolment model
-- Place DROP commands at head of schema file
commit;
-- 7.3.2
-- Using sequences for INSERT
--
===============================================================
=
-- Create sequence
create sequence student_seq start with 11111115 increment by 1;
-- Add an enrolment
insert into enrolment values (student_seq.currval, 'FIT5132', 2016, '2', null, null);
commit;
-- 7.3.3
-- Advanced Insert
--
===============================================================
=
commit;
-- 7.3.4
-- Create table and Insert data from a single SQL statement
--
===============================================================
=
commit;