les10 creating and managing tables

Download Les10 Creating And Managing Tables

Post on 25-May-2015

2.424 views

Category:

Entertainment & Humor

2 download

Embed Size (px)

TRANSCRIPT

  • 1. Creating and Managing Tables

2. Objectives
After completing this lesson, you should be able to do the following:
Describe the main database objects
Create tables
Describe the datatypes that can be used when specifying column definition
Alter table definitions
Drop, rename, and truncate tables
3. Database Objects
ObjectDescription
TableBasic unit of storage; composed of rowsand columns
View Logically represents subsets of data fromone or more tables
Sequence Generates primary key values
IndexImproves the performance of some queries
Synonym Gives alternative names to objects
4. Naming Conventions
Must begin with a letter
Can be 130 characters long
Must contain only AZ, az, 09, _, $, and #
Must not duplicate the name of another object owned by the same user
Must not be an Oracle Server reserved word
5. The CREATE TABLE Statement
You must have :
CREATE TABLE privilege
A storage area
You specify:
Table name
Column name, column datatype, and column size
CREATE TABLE [schema.]table
(columndatatype [DEFAULT expr][, ...]);
6. Referencing Another Users Tables
Tables belonging to other users are not in the users schema.
You should use the owners name as a prefix to the table.
7. The DEFAULT Option
Specify a default value for a column during an insert.
hiredate DATE DEFAULT SYSDATE,

  • Legal values are literal value, expression, or SQL function.

8. Illegal values are another columns name or pseudocolumn. 9. The default datatype must match the column datatype.