13. Multi-row Insert Bookstore SQL212 Module 3 Basic Syntax: Insert [into] <table-name> Select <select-statement> We will do this after creating a new table later in this module
28. Create Table Bookstore SQL212 Module 3 Basic syntax: Create table <table-name> <column1> <datatype> <constraints> ,.. <column1> <datatype> <constraints> … <table constraints> Note: often preceded by a drop
29. Temporary Tables Bookstore SQL212 Module 3 Basic syntax: Create [global] temporary table <table-name> <rest of statement as for normal create> Note: SQL Server uses a different syntax. Just put a #in front of the table name as in #mytable. Access doesn’t have true temporary tables.
30.
31.
32.
33. Create Table Bookstore SQL212 Module 3 Example 1: Create a summary table Create table summary( isbn varchar2(20) primary key , How_many int check (how_many >= 0), Constraint isbn_fk Foreign key (isbn) references books(isbn) )
37. Multi-row Insert Bookstore SQL212 Module 3 Basic Example: (store # times each book ordered) Insert into summary(isbn, how_many) Select isbn, count(*) From orderlines Group by isbn;
47. Indexes Bookstore SQL212 Module 3 Basic syntax: Create [unique] index <index-name> On <table-name> (field-name> [desc]) Note: can place index on a composite key; ex: state and city
59. Grant Bookstore SQL212 Module 3 Syntax: Grant <access-right> [with grant option] On <object> to <user> Note: by default only tables owners and admins can access a table. Others must be granted the relevant rights.
60.
61. Grant Bookstore SQL212 Module 3 Example: Give user ddurso the permission to update the employees table. Grant update On employees to ddurso