Presentation is loading. Please wait.

Presentation is loading. Please wait.

Oracle Developer. Create Table SQL> create table catalog ( 2 cno varchar2(7), 3 ctitle varchar2(50), 4 primary key (cno)); Table created. SQL> describe.

Similar presentations


Presentation on theme: "Oracle Developer. Create Table SQL> create table catalog ( 2 cno varchar2(7), 3 ctitle varchar2(50), 4 primary key (cno)); Table created. SQL> describe."— Presentation transcript:

1 Oracle Developer

2 Create Table SQL> create table catalog ( 2 cno varchar2(7), 3 ctitle varchar2(50), 4 primary key (cno)); Table created. SQL> describe catalog; Name Null? Type ------------------------------- -------- ---- CNO NOT NULL VARCHAR2(7) CTITLE VARCHAR2(50)

3 Create Table SQL> create table students ( 2 sid varchar2(5), 3 fname varchar2(20), 4 lname varchar2(20) not null, 5 minit char, 6 primary key (sid)); Table created. SQL> describe students; Name Null? Type ------------------------------- -------- ---- SID NOT NULL VARCHAR2(5) FNAME VARCHAR2(20) LNAME NOT NULL VARCHAR2(20) MINIT CHAR(1)

4 SQL> create table courses ( 2 term varchar2(10), 3 lineno number(4), 4 cno varchar2(7) not null, 5 a number(2) check (a>0), 6 b number(2) check(b>0), 7 c number(2) check (c>0), 8 d number(2) check(d>0), 9 primary key (term, lineno), 10 foreign key (cno) references catalog); Table created. Create table with foreign key

5 SQL> Describe courses; Name Null? Type ------------------------------- -------- ---- TERM NOT NULL VARCHAR2(10) LINENO NOT NULL NUMBER(4) CNO NOT NULL VARCHAR2(7) A NUMBER(2) B NUMBER(2) C NUMBER(2) D NUMBER(2)

6 SQL> create table components ( 2 term varchar2(10), 3 lineno number(4) check(lineno >= 1000), 4 compname varchar2(15), 5 maxpoints number(4) not null check(maxpoints >= 0), 6 weight number(2) check(weight >= 0), 7 primary key (term, lineno, compname), 8 foreign key (term, lineno) references courses); Table created. Primary key consists of three attributes

7 SQL> Describe components; Name Null? Type ------------------------------- -------- ---- TERM NOT NULL VARCHAR2(10) LINENO NOT NULL NUMBER(4) COMPNAME NOT NULL VARCHAR2(15) MAXPOINTS NOT NULL NUMBER(4) WEIGHT NUMBER(2) Primary key consists of three attributes

8 SQL> create table enrolls ( 2 sid varchar2(5), 3 term varchar2(10), 4 lineno number(4), 5 primary key (sid, term, lineno), 6 foreign key (sid) references students, 7 foreign key (term, lineno) references courses); Two foreign keys

9 SQL> describe enrolls; Name Null? Type ------------------------------- -------- ---- SID NOT NULL VARCHAR2(5) TERM NOT NULL VARCHAR2(10) LINENO NOT NULL NUMBER(4)

10 SQL> create table scores ( 2 sid varchar2(5), 3 term varchar2(10), 4 lineno number(4), 5 compname varchar2(15), 6 points number(4) check(points >=0), 7 primary key (sid, term, lineno, compname), 8 foreign key (sid, term, lineno) references enrolls, 9 foreign key (term, lineno, compname) references components);

11 SQL> describe scores; Name Null? Type ------------------------------- -------- ---- SID NOT NULL VARCHAR2(5) TERM NOT NULL VARCHAR2(10) LINENO NOT NULL NUMBER(4) COMPNAME NOT NULL VARCHAR2(15) POINTS NUMBER(4)

12 Oracle Developer - Form Builder

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32 SQL> select * from catalog; CNO CTITLE ------- -------------------------------------------------- csc226 Introduction to Programming csc227 Introduction to Programming II csc343 Assembly programming csc481 Automata and Formal Languages csc498 Introduction to Database and Logic programming

33 Oracle Developer - Query Builder

34

35

36

37

38

39 Oracle - Report Builder

40

41

42

43

44

45

46

47

48

49

50

51

52

53


Download ppt "Oracle Developer. Create Table SQL> create table catalog ( 2 cno varchar2(7), 3 ctitle varchar2(50), 4 primary key (cno)); Table created. SQL> describe."

Similar presentations


Ads by Google