تصميم قواعد البيانات ولغة SQL

  • Published on
    20-Mar-2016

  • View
    132

  • Download
    5

Embed Size (px)

DESCRIPTION

SQL. SQL : ( Data Definition Language ( DDL Data Manipulation Language ( DML ). SQL. SQL. - PowerPoint PPT Presentation

Transcript

PowerPoint Presentation

T. Aishah Khawaji1 SQL

T. Aishah Khawaji2

T. Aishah Khawaji3 SQL SQL : ( Data Definition Language ( DDL Data Manipulation Language ( DML )T. Aishah Khawaji4 SQL

T. Aishah Khawaji5 SQL: SQL . :CREATE TABLE INSTRUCTORCreate table instructor2. ( ,). :( deptno , dname )

3. SQL . :SELECT employee_id, last_name, job_id, salary

T. Aishah Khawaji6 SQL:4. , Keywords . :( CREATE , DROP, SELECT, ORDER BY )

5. .6. ( ;). :CREATE TABLE INSTRUCTOR;

T. Aishah Khawaji7

T. Aishah Khawaji8T. Aishah Khawaji9INSTRUCTOR ( Inst# , Name , Rank , Salary , Gender , Dept# )STUDENT ( S# , Name , Address, Bdate, Dept# )DEPARTMENT ( Dep# , Name , Location )COURSE ( Code , Title , Ctedit_hours )TEACH ( Inst# , Course# , Semester , Year )STUDY ( Student# , Course# , Semester , Year , Gender )

. . .T. Aishah Khawaji10 : CRATE CREATE TABLE INSTRUCTOR ( Inst# NUMBER UNIQUE NOT NULL,Name VARCHAR (40) NOT NULL,Salary NUMBER (8,2), Gender CHAR (1), Dept# NUMBER FOREIGN KEY (Dept#) REFERENCES DEPARTMENT (Dept#) ) ; T. Aishah Khawaji11 DDLPRIMARY KEY ( ) T. Aishah Khawaji12CREATE TABLE student ( st# NUMBER(4) PRIMARY KEY,Name VARCHAR(30) NOT NULL,Address CHAR (40), Bdate DATE , Dept# NUMBER,FOREIGN KEY (Dept#) REFERENCES DEPARTMENT (Dept#) ) ;

CREATE TABLE department ( D# NUMBER PRIMARY KEY,Name CHAR(30) NOT NULL,Location CHAR (10) ) ;T. Aishah Khawaji13 CREATE TABLE COURSE ( Cor# CHAR(6) PRIMARY KEY,Title CHAR(20) NOT NULL, Credit_hours NUMBER ) ;

CREATE TABLE TEACH ( inst# NUMBER, Cor# CHAR(6), Semester NUMBER, Year NUMBER,PRIMARY KEY (inst#, Cor#) ) ;

CREATE TABLE STUDY ( st# NUMBER, Cor# CHAR(6), Semester NUMBER, Year NUMBER,PRIMARY KEY (st#, Cor#) ); DROPDROP TABLE student ;

CASECADE RESTRICTDROP TABLE student CASECADE ;

DROP TABLE student RESTRICT ;

T. Aishah Khawaji14 DROP DROP DESCRIBE ( ) .DESCRIBE student ;DESC student ; :

T. Aishah Khawaji15

ALTER :ALTER TABLE department ADD Colg# NUMBER ; :ALTER TABLE department DROP COLUMN LOCATIO ; :ALTER TABLE INSTRUCTOR DROP (Rank, Gender) ; :ALTER TABLE department MODIFY Location CHAR(30) ) ;

T. Aishah Khawaji16 ALTER

:RENAME department TO DEPT;

ALTER TABLE INSTRUCTOR RENAME COLUMN Dept# TO DEPARTMENT# ;

T. Aishah Khawaji17 ( )T. Aishah Khawaji18 DML INSERT SELECT UPDATE DELETE.T. Aishah Khawaji19 DML INSERT SQL.

INSERT INTO INSTRUCTOR VALUES (676, Khadiga, Prof, 15000,f, 2) ;

INSERT INTO student VALUES (420, Fahad, Qassim, 09-10-1963, 2) ;

T. Aishah Khawaji20 INSERT : VALUES . NULL. CHAR DATE .

. T. Aishah Khawaji21

Recommended

View more >