SQL Lectures 1 and 2

  1. Command to create a relation
    • create table [table_name] (
    •     [attr_name] [data_type], ...,
    •     primary key ([attribute_name], ...)
    •     foreign key ([attribute_name], ...) references
    •         [other_table]([attributes from other table])
    •     on [foreign_key_condition] [action] %Can repeat%
    • );
  2. One delete/update actions
    • Cascade
    • Set null
    • Restrict (no action)
  3. Command to insert a tuple (known order of attributes)
    insert into [table_name] values ([value_name], ...)
  4. Command to insert a tuple (user specified values)
    insert into [table_name]([attribute_name], ...) values ([attribute_name], ...)
  5. Command to delete all tuples from a table
    delete from [table_name]
  6. Command to delete specific tuples from a table
    • delete from [table_name] where [selection_predicate]
    • Update is the same, just replace 'delete' with 'update'
  7. command to retrieve all information from a table
    select * from [table_name]
  8. Retrieve specific values from a table
    select [value_name], .... from [table_name];
  9. Retrieve data from multiple tables
    • select [attribute], ...
    • from [table], ...
    • where [join_conditions], ... and [selection_conditions], ...
Author
Ant
ID
356624
Card Set
SQL Lectures 1 and 2
Description
Updated