SQL COMMANDS - PowerPoint PPT Presentation

About This Presentation
Title:

SQL COMMANDS

Description:

Create, Alter and Remove Tables from the Database. Insert Command ... Alter Table Command. Change the table structure in a pre-existing table ... – PowerPoint PPT presentation

Number of Views:574
Avg rating:3.0/5.0
Slides: 12
Provided by: aleksko
Category:

less

Transcript and Presenter's Notes

Title: SQL COMMANDS


1
SQL COMMANDS
  • Insert, Update and the rest

2
Lecture Objectives
  • Utilize the standard query language (SQL) to
    perform the following tasks
  • Add Rows to the Database
  • Change Existing Rows in the Database
  • Delete Rows from the Database
  • Create, Alter and Remove Tables from the Database

3
Insert Command
  • Allows the insertion of data into a table one row
    at a time
  • Used for new tables, or tables with existing data
  • What about NULL values?

4
Insert Command
  • Alternate syntax
  • When will Insert NOT Work?

5
Update Command
  • Modify an attribute of one or more rows in a
    given table
  • When will Update NOT Work?

6
Delete Command
  • Removes rows from a single table
  • Will delete ever remove from more than one table?

7
Create Table Command
  • Creates a new relation/table by giving the name,
    attributes and constraints on the table
  • This is a water-downed version of the command

Name of New Table
Syntax CREATE TABLE lttbl_namegt (
column1 datatype constraint,
column2 datatype constraint, . . PRIMA
RY KEY (column1, column2, ) FOREIGN KEY
(column1, column2, ) REFERENCES
lttbl_name2gt)
Column Names
Set Primary and Foreign Keys
8
Create Table Command
  • Data types a few examples
  • Numeric Data types NUMBER(I,D) INTEGER S
    MALLINT DECIMAL(I,D)
  • Character Data types CHAR(L) VARCHAR(L)
  • Date DATE

9
Alter Table Command
  • Change the table structure in a pre-existing table
  • Note more options available for the alter command

10
Drop Table Command
  • Remove the table and its data from the database

11
Examples
Write a Comment
User Comments (0)
About PowerShow.com