Presentation is loading. Please wait.

Presentation is loading. Please wait.

Constraints  Constraints are used to enforce rules at table level.  Constraints prevent the deletion of a table if there is dependencies.  The following.

Similar presentations


Presentation on theme: "Constraints  Constraints are used to enforce rules at table level.  Constraints prevent the deletion of a table if there is dependencies.  The following."— Presentation transcript:

1 Constraints  Constraints are used to enforce rules at table level.  Constraints prevent the deletion of a table if there is dependencies.  The following constraints types are valid in : Not Null Default Unique Primary key Foreign key

2 Constraints (Example) CREATE TABLE student( IDNumber(8), NameVarchar2(15), GPA Number(3,2), MajorVarchar2(5) Not Null, DOBDate, PRIMARY KEY (ID), UNIQUE (Name) );

3 Adding Constraints  Table Level  Using ALTER Table command Syntax: ALTER TABLE ADD CONSTRAINTS

4 Dropping Constraints  To drop a constraint we use ALTER table command Ex. ALTER TABLE student DROP constraint GPA_ck;

5 Insert In the Tables  Syntax INSERT INTO [(column[,column,..])] values (‘…’,’ …’, …. );  Only one row is inserted at a time with this syntax.

6 Updating Rows ’ Values  Syntax: UPDATE SET = value [,column=value, …] [WHRER condition];

7 Delete  Syntax: DELETE FROM [WHERE condition];

8 Basic Queries in SQL  SQL has one basic statement for retrieving information from a database The Select Statement

9  The basic form of select statement is formed of three clauses SELECT, FROM and WHERE  SELECT  FROM  WHERE ; The SELECT-FROM-WHERE structure

10 SQL Statement  is a list of attribute names whose values are to be retrieved by the query.  is a list of the relation (table) names required to process the query.  is a conditional (Boolean) expression that identifies the records to be retrieved by the query.


Download ppt "Constraints  Constraints are used to enforce rules at table level.  Constraints prevent the deletion of a table if there is dependencies.  The following."

Similar presentations


Ads by Google