Documente Academic
Documente Profesional
Documente Cultură
Housekeeping:
Attendance sheet Expectations next few weeks SDLC extended doc posted in course documents Log-in info
ORACLE
Database commands Class work/Lab Quiz
Oracle 10g: SQL 1
10
11
12
13
Column Aliases
? Write a select statement to pull data from the title column using the alias title of books and from the category column.
14
15
16
17
18
19
Using Concatenation
You can combine data with a string literal Use the concatenation operator, || It allows the use of column aliases
20
Concatenation Example
21
22
Database Table
A database object Stores data for the database Consists of columns and rows Created and modified through data definition language (DDL) commands
24
Table Design
Table and column names:
Can contain a maximum 30 characters - no blank spaces Must begin with a letter Can contain numbers, underscore (_), and number sign (#) Must be unique No reserved words are allowed
Oracle 10g: SQL 25
26
Table Creation
27
Defining Columns
Column definition list must be enclosed in parentheses Datatype must be specified for each column Maximum of 1,000 columns
28
30
31
32
33
CREATE TABLEAS
34
Create table AS
? Table name to be created cust_mkt Base this table on the table customers and the following columns from the customers table: customer #, city, state, zip and referred. Use a subquery.
35
36
37
38
Alter Table
? Alter the table named publisher Add the column ext of data type number length 4
39
40
41
Modification Guidelines
Column must be as wide as the data it already contains If a NUMBER column already contains data, size cannot be decreased Adding or changing default data does not affect existing data
42
43
44
45
Renaming a Table
RENAMETO is used to rename a table the old name is no longer valid
46
Truncating a Table
TRUNCATE TABLE command - rows are deleted Structure of table remains
47
Deleting a Table
DROP TABLE command - table structure and contents are deleted
48
49
FLASHBACK Command
The FLASHBACK command recovers a table from the recycle bin
50
51
52