SQL Lesson 2 tutorial
SQL Lesson 2 tutorial
Lesson 2
1
SQL Comments
SQL Data Types
SQL Constraints
SQL SELECT Statement
SQL WHERE clause 2
The TIME data type has at least eight positions, with the components
HOUR, MINUTE, and SECOND, typically in the form HH:MM:SS.
TIME
includes both the DATE and TIME fields, plus a minimum of six positions
for fractions of seconds and an optional WITH TIME ZONE qualifier.
TIMESTAMP
8
10
Constraints…
• Following are commonly used constraints available in SQL:
1. NOT NULL Constraint
2. DEFAULT Constraint
3. UNIQUE Constraint
4. PRIMARY KEY
5. FOREIGN KEY
6. CHECK Constraint
11
12
14
• Here STUD_ID column is set to UNIQUE, so that you can not have two
records with same STUD_ID.
15
• Here we add a CHECK with STUD_AGE column, so that you cannot have any student below 18 years.
22
23
• Syntax:
SELECT <attribute list> FROM <table list>
• <table list> is a list of the relation names required to process the query.
24
If you want to fetch all the fields available in the table then you can use following syntax:
26
27