Structured Query Language: C-Dac Hyderabad
Structured Query Language: C-Dac Hyderabad
Relational Database
Dr. E.F. Codd proposed the relational model for
Set of operators to act on the relations Data integrity for accuracy and consistency
C-DAC Hyderabad
3.2
Definition of Relational DB
A relational database is a collection of relations or
two-dimensional tables.
C-DAC Hyderabad
3.3
Relational Concepts
A relational database is a collection of data where
logically related data is grouped into tables (files) within the database
Rows (records) appear horizontally in a report, and
C-DAC Hyderabad
3.4
Data Model
C-DAC Hyderabad
3.5
pointers
C-DAC Hyderabad
3.6
C-DAC Hyderabad
3.7
C-DAC Hyderabad
3.8
C-DAC Hyderabad
3.9
SQL Statements
C-DAC Hyderabad
3.10
Summary
Oracle9i is based on the object relational database
management system.
Relational databases are composed of relations,
C-DAC Hyderabad
3.11
DDL Commands
For Creating and Managing Tables
C-DAC Hyderabad
3.13
Naming Rules
Table Names and Column Names
Must begin with a letter Must be 130 characters long Must contain only AZ, az, 09, _, $, and # Must not be an Oracle server reserved word
C-DAC Hyderabad
3.14
C-DAC Hyderabad
3.15
an insert.
The default data type must match the column
data type.
Literal values, expressions, or SQL functions
C-DAC Hyderabad
3.16
DATA TYPES
C-DAC Hyderabad
3.17
Creating Tables
Example: Create table
CREATE TABLE dept (deptno NUMBER(2), dname VARCHAR2(14), loc VARCHAR2(13)); Table created.
Confirm table creation.
DESCRIBE dept
C-DAC Hyderabad
3.18
Are a collection of tables created and maintained by the user. Contain user information
Data Dictionary :
Is a collection of tables created and maintained by the Oracle Server. Contain database information
C-DAC Hyderabad
3.19
You can logically relate data from multiple tables using foreign keys (FK).
C-DAC Hyderabad
3.20
C-DAC Hyderabad
3.21
drop columns.
C-DAC Hyderabad
3.22
Adding a Column
You use the ADD clause to add columns.
The new column becomes the last column
C-DAC Hyderabad
3.23
Modifying A Column
You can change a columns data type, size, and
default value.
C-DAC Hyderabad
3.24
Dropping a Column
Use the DROP COLUMN clause to drop columns
C-DAC Hyderabad
3.25
Dropping a Table
All data and structure in the table is deleted.
Any pending transactions are committed. You cannot roll back the DROP TABLE statement.
C-DAC Hyderabad
3.26
C-DAC Hyderabad
3.27
Truncating a Table
The TRUNCATE TABLE statement:
-Removes all rows from a table -Releases the storage space used by that table
You cannot roll back row removal when using TRUNCATE. DELETE statement.
C-DAC Hyderabad
3.28
Summary
C-DAC Hyderabad
3.29