1 / 14

Intro to SQL

Intro to SQL. Log on and set password. Exit, Rollback, Commit. Case sensitivity, spacing, end of sentence. Spacing not relevant BUT… no spaces in an attribute name or table name Oracle commands keywords, table names, and attribute names not case sensitive

chakra
Download Presentation

Intro to SQL

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Intro to SQL

  2. Log on and set password Intro to SQL| MIS 2502

  3. Exit, Rollback, Commit Intro to SQL| MIS 2502

  4. Case sensitivity, spacing, end of sentence • Spacing not relevant • BUT… no spaces in an attribute name or table name • Oracle commands keywords, table names, and attribute names not case sensitive • Entering and retrieving string values are case sensitive • To end sentence -> ; Intro to SQL| MIS 2502

  5. USE NOTEPAD! • SQL plus’ editor is a pain! • Enter code in notepad and then copy and paste at prompt in SQL plus • Hit enter to run command Intro to SQL| MIS 2502

  6. Delete a table • Drop table • Cascade constraints!!! – enforces that no delete anomolies • Drop table manager cascade constraints; Intro to SQL| MIS 2502

  7. Important data types… • Char • Varchar • Number • Date • Integer Intro to SQL| MIS 2502

  8. Create table syntax CREATE TABLE <tablename> (<fieldname> <data declaration> … [CONSTRAINT <integrity constraint declaration>… ); CREATE TABLE bank_customer ( Customer_ID NUMBER(5) constraint customer_id primary key, Customer_LastName VARCHAR2(30) not null, Customer_FirstName VARCHAR2(30) not null, Customer_MI Char(1) null, Add1 VARCHAR2(30) not null, City VARCHAR2(25) not null, State CHAR(2) not null, Zip CHAR(5) not null ); Don’t need not null since PK cannot be null No comma since last attribute Intro to SQL| MIS 2502

  9. To show a table design - Describe • Describe tablename -> describe customer Intro to SQL| MIS 2502

  10. Alter • Can change following in a table: • attribute names, size, data types • Remove and add attributes • Cannot change a field from null to not null. • For FK – can’t reference a field that doesn’t exist. That’s why I’ve had you add the tables and attributes first and then reference them with the Alter command Intro to SQL| MIS 2502

  11. Alter table – adding/ modifying attributes Intro to SQL| MIS 2502

  12. Alter – Constraints Intro to SQL| MIS 2502

  13. Alter – Constraints Intro to SQL| MIS 2502

  14. Note - Strings • Text must be entered in single quotes… ‘PA’ Intro to SQL| MIS 2502

More Related