Professional Documents
Culture Documents
5 - SQL Creating New Table
5 - SQL Creating New Table
New Table
Creating New Table From
Another Table
2
Creating New Table From
Another Table
• Problem:
3
Creating New Table From
Another Table
• Example 1:
5
The CREATE TABLE USING
SELECT INTO Structure
Results:
6
Creating New Table From
Another Table
• Example 2:
• CustomerNum, CustomerName,
Balance, CreditLimit and RepNum.
7
Creating New Table From
Another Table
9
The CREATE TABLE USING
SELECT INTO Structure
Results:
10
The SQL UPDATE Command
11
The SQL UPDATE Command
12
The SQL UPDATE Command
• Syntax:
UPDATE TableName then type
SET (column name and the new
value) then the
WHERE clause (column name and the
value that you want to change)
The SQL UPDATE Command
14
The SQL UPDATE Command
Results:
15
The SQL INSERT Command
16
The SQL INSERT Command
17
The SQL INSERT Command
• Add Customer Number 895 to the
SmallCustomer table. The name is Peter and
Margaret’s, the balance is 0, the credit limit is
$8,000, and the rep number is 20.
18
The SQL INSERT Command
Results:
19
The SQL DELETE Command
20
The SQL DELETE Command
21
The SQL DELETE Command
22
The SQL DELETE Command
Results:
23
The SQL ALTER Command
24
The SQL ALTER Command
26
Changing a Table’s Definition
27
Adding a Column in a Table
28
Adding a Column in a Table
Example:
• Premiere Products decides to maintain a
Customer Type for each customer in the
database. These type are R, for Regular
customers, D for Distributors, and S for
Special customers.
30
Updating a Column in a Table
31
Updating a Column in a Table
Results:
32
Updating a Column in a Table
33
Updating a Column in a Table
34
Updating a Column in a Table
Results:
35
Modifying a Column in a Table
Example 1:
36
Modifying a Column in a Table
37
Modifying a Column in a Table
Example 2:
38
Modifying a Column in a Table
39
Results
40
Thank you for listening!