Exemplo de create table

Disponível somente no TrabalhosFeitos
  • Páginas : 2 (267 palavras )
  • Download(s) : 0
  • Publicado : 17 de maio de 2012
Ler documento completo
Amostra do texto
set termout off
DROP TABLE PROFESSOR CASCADE CONSTRAINT;
DROP TABLE CARGO CASCADE CONSTRAINT;
DROP TABLE DEPTO CASCADE CONSTRAINT;

CREATE TABLE CARGO (
CODIGO NUMBER(2) NOTNULL,
DESCRICAO VARCHAR2(20),
CONSTRAINT CARGO_PRIMARY_KEY PRIMARY KEY (CODIGO));
INSERT INTO CARGO VALUES (1,'MESTRANDO');
INSERT INTO CARGO VALUES (2,'MESTRE');
INSERT INTOCARGO VALUES (3,'DOUTORANDO');
INSERT INTO CARGO VALUES (4,'DOUTOR');

CREATE TABLE DEPTO (
CODIGO NUMBER(2) NOT NULL,
DESCRICAO VARCHAR2(20),
CONSTRAINTDEPTO_PRIMARY_KEY PRIMARY KEY (CODIGO));
INSERT INTO DEPTO VALUES (1,'COMPUTACAO');
INSERT INTO DEPTO VALUES (2,'MATEMATICA');
INSERT INTO DEPTO VALUES (3,'SECRETARIADO');
INSERT INTO DEPTO VALUES(4,'ESPECIALIZACAO');

CREATE TABLE PROFESSOR (
CODIGO NUMBER(4) NOT NULL,
NOME VARCHAR2(30),
NASCIMENTO DATE,
SALARIO NUMBER(7,2),
CARGONUMBER(2) NOT NULL,
DEPTO NUMBER(2) NOT NULL,
CONSTRAINT PROFESSOR_DEPTO_FK FOREIGN KEY (DEPTO) REFERENCES DEPTO (CODIGO),
CONSTRAINT PROFESSOR_CARGO_FK FOREIGNKEY (CARGO) REFERENCES CARGO (CODIGO),
CONSTRAINT PROFESSOR_CODIGO_PK PRIMARY KEY (CODIGO));
INSERT INTO PROFESSOR VALUES (0001,'ALEX','17-11-1971',1500,1,1);
INSERT INTO PROFESSOR VALUES(0002,'ALMIR','01-05-1971',1500,2,1);
INSERT INTO PROFESSOR VALUES (0003,'BEGOSSO','9-06-1971',1450,3,2);
INSERT INTO PROFESSOR VALUES (0004,'GUTO','2-04-1971',1700,3,2);
INSERT INTO PROFESSORVALUES (0005,'TALO','28-09-1971',1850,3,1);
INSERT INTO PROFESSOR VALUES (0006,'DOMINGOS','20-02-1971',1600,1,3);
INSERT INTO PROFESSOR VALUES (0007,'OSMAR','8-09-1971',1500,1,1);
INSERT INTOPROFESSOR VALUES (0008,'URSO','3-12-1971',1950,2,1);
INSERT INTO PROFESSOR VALUES (0009,'FABIO','22-02-1971',1350,2,1);
INSERT INTO PROFESSOR VALUES (0010,'DOUGLAS','3-12-1971',2000,1,1);

/
tracking img