Database Design Sections 12 & 15 - Introduction to Application Express (APEX) SQL editor, Introduction to SQL statements.

Slides:



Advertisements
Similar presentations
Creating Tables. 2 home back first prev next last What Will I Learn? List and provide an example of each of the number, character, and date data types.
Advertisements

SQL Rohit Khokher.
Manipulating Data Schedule: Timing Topic 60 minutes Lecture
Virtual training week 4 structured query language (SQL)
SQL Review Sections 1 - SQL and other basic statements.
Writing Basic SQL SELECT Statements. Capabilities of SQL SELECT Statements A SELECT statement retrieves information from the database. Using a SELECT.
Introduction to Structured Query Language (SQL)
Introduction to Structured Query Language (SQL)
SQL components In Oracle. SQL in Oracle SQL is made up of 4 components: –DDL Data Definition Language CREATE, ALTER, DROP, TRUNCATE. Creates / Alters.
Introduction to Oracle9i: SQL1 Basic SQL SELECT Statements.
8 Copyright © Oracle Corporation, All rights reserved. Manipulating Data.
1 Copyright © Oracle Corporation, All rights reserved. Writing Basic SQL SELECT Statements.
A Guide to SQL, Seventh Edition. Objectives Understand the concepts and terminology associated with relational databases Create and run SQL commands in.
Writing Basic SQL statement 2 July July July Create By Pantharee Sawasdimongkol.
Introduction to Structured Query Language (SQL)
WRITING BASIC SQL SELECT STATEMENTS Lecture 7 1. Outlines  SQL SELECT statement  Capabilities of SELECT statements  Basic SELECT statement  Selecting.
Chapter 1 Writing Basic SQL Statements Important Legal Notice:  Materials on this lecture are from a book titled “Oracle Education” by Kochhar, Gravina,
Ceng 356-Lab1. Objectives After completing this lesson, you should be able to do the following: Get Familiar with the development environment List the.
Structured Query Language S Q L. What is SQL It is a database programming language developed by IBM in the early 1970’s. It is used for managing and retrieving.
1 Copyright © Oracle Corporation, All rights reserved. Writing Basic SQL SELECT Statements.
A Guide to SQL, Eighth Edition Chapter Three Creating Tables.
Chapter 2 Basic SQL SELECT Statements
Project Implementation for COSC 5050 Distributed Database Applications Lab2.
Chapter 2 Basic SQL SELECT Statements Oracle 10g: SQL.
I Copyright © 2004, Oracle. All rights reserved. Introduction.
1 Copyright © 2006, Oracle. All rights reserved. Retrieving Data Using the SQL SELECT Statement.
I Copyright © Oracle Corporation, All rights reserved. Introduction.
After completing this lesson, you should be able to do the following: List the capabilities of MySQL SELECT statements Execute a basic SELECT statement.
SQL (DDL & DML Commands)
SQL SQL Server : Overview SQL : Overview Types of SQL Database : Creation Tables : Creation & Manipulation Data : Creation & Manipulation Data : Retrieving.
2 Writing Basic SELECT Statements. 1-2 Copyright  Oracle Corporation, All rights reserved. Capabilities of SQL SELECT Statements Selection Projection.
Copyright  Oracle Corporation, All rights reserved. Writing Basic SQL Statements.
RELATSIOONILISED ANDMEBAASID(alg) SQLi VÕIMALUSED.
7 1 Chapter 7 Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
Oracle 11g DATABASE DEVELOPMENT LAB1. Introduction  Oracle 11g Database:-  Oracle 11g database is designed for some features, which helps to the organizations.
6 1 Lecture 8: Introduction to Structured Query Language (SQL) J. S. Chou, P.E., Ph.D.
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
Introduction to SQL PART Ⅰ 第一讲 Writing Basic SQL SELECT Statements.
SQL Basics. What is SQL? SQL stands for Structured Query Language. SQL lets you access and manipulate databases.
Database Lab Lecture 1. Database Languages Data definition language ( DDL ) Data definition language –defines data types and the relationships among them.
1 Writing Basic SQL Statements. 1-2 Objectives At the end of this lesson, you should be able to: List the capabilities of SQL SELECT statements Execute.
Copyright © 2004, Oracle. All rights reserved. Lecture 4: 1-Retrieving Data Using the SQL SELECT Statement 2-Restricting and Sorting Data Lecture 4: 1-Retrieving.
AL-MAAREFA COLLEGE FOR SCIENCE AND TECHNOLOGY INFO 232: DATABASE SYSTEMS CHAPTER 7 (Part II) INTRODUCTION TO STRUCTURED QUERY LANGUAGE (SQL) Instructor.
Database Programming Sections 14– database transactions and controlling User Access.
Database Design Sections 13 & 16 - Introduction to HTML DB SQL editor, Introduction to SQL statements.
Working with Columns, Characters, and Rows. 2 home back first prev next last What Will I Learn? In this lesson, you will learn to: –Apply the concatenation.
1 Copyright © Oracle Corporation, All rights reserved. Writing Basic SQL SELECT Statements.
1 Chapter 2 Basic SQL SELECT Statements. 2 Chapter Objectives Distinguish between an RDBMS and an ORDBMS Identify keywords, mandatory clauses, and optional.
1-1 Copyright  Oracle Corporation, All rights reserved. Logging In to SQL*Plus From Windows environment:From Windows environment: From command line:From.
7 1 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel 7.6 Advanced Select Queries SQL provides useful functions that.
Writing Basic SQL Statements. Objectives After completing this lesson, you should be able to do the following: –List the capabilities of SQL SELECT statements.
MICROSOFT ACCESS – CHAPTER 5 MICROSOFT ACCESS – CHAPTER 6 MICROSOFT ACCESS – CHAPTER 7 Sravanthi Lakkimsety Mar 14,2016.
1 Copyright © 2007, Oracle. All rights reserved. Retrieving Data Using the SQL SELECT Statement.
Oracle 10g Retrieving Data Using the SQL SELECT Statement.
1 Copyright © 2009, Oracle. All rights reserved. Retrieving Data Using the SQL SELECT Statement.
1 Section 1 - Introduction to SQL u SQL is an abbreviation for Structured Query Language. u It is generally pronounced “Sequel” u SQL is a unified language.
Oracle 11g: SQL Chapter 5 Data Manipulation and Transaction Control.
1 Copyright © 2005, Oracle. All rights reserved. Oracle Database Administration: Overview.
Copyright س Oracle Corporation, All rights reserved. 1 Writing Basic SQL Statements.
1 Copyright © 2004, Oracle. All rights reserved. Retrieving Data Using the SQL SELECT Statement.
Retrieving Data Using the SQL SELECT Statement
Writing Basic SQL SELECT Statements
Manipulating Data.
Writing Basic SQL SELECT Statements
SQL 101.
Sections 1 - SQL and other basic statements
Sections 1 - SQL and other basic statements
Writing Basic SQL SELECT Statements
Contents Preface I Introduction Lesson Objectives I-2
Presentation transcript:

Database Design Sections 12 & 15 - Introduction to Application Express (APEX) SQL editor, Introduction to SQL statements

Using APEX SQL editor You may either type the command into the SQL editor or use the cut and paste option If you are going to cut/paste the command copy the command from the word document into NotePad. This will drop out hidden characters. Next copy the command from the NotePad into the editor Have student open/save the Basic SQL commands in section 0 for section 12 in the additional resources sections. Point out the Apex guide is also available there. They may also want to download the music.sql script file onto their USB drives. Point out the following links/documents in section 15 that they should download. Students should also print out the excel sheet for the 3 main tables in APEX from the website. These include the database tables and ERD’s. Also download from my website http://www.cerritos.edu/hohly the data for the tables in an excel worksheet. This is available in the student resources section. Marge Hohly

Enter SQL command Change the Display function to a number larger than 10. This will allow all records of a table or query to be displayed. Enter the above text into the APEX SQL editor to create a table called Music. Marge Hohly

Display the Table structure Enter the following command: DESCRIBE music; The structure of the table should be shown. Results on next slide Slide 5: Tell Me /Show Me – The DESCRIBE command displays the structure … Syntax- The rules governing the formation of statements in a programming language. Write the DESCRIBE music syntax and ask students to enter the SQL command. Discuss what the statement means and what it returns. Run command. Review APEX where you see tables etc. Marge Hohly

Music Table Structure MUSIC table: Row – describes a music (instance) Column – attribute of each employee Marge Hohly

Select command structure SELECT field1, field2, field3 FROM table_name WHERE condition; Try the following command SELECT employee_id, first_name, last_name, department_id FROM employees; SELECT employee_id, first_name, last_name, department_id FROM employees WHERE department_id = 90; Try the above commands Slide 6: Tell Me /Show Me – The SELECT * command returns all the rows… Write the SELECT * FROM music syntax on the board. Ask students to enter the SQL command. Discuss what the statement means and what it returns. Select clause limits the columns displayed Slide 7: Tell Me /Show Me – To return a subset of the data, modify the SELECT … Explain that the <condition> often takes the form of column name + operator (=, >, <, IS NULL, IS NOT NULL, etc.). Where limits the rows displayed. Marge Hohly

Resulting Screen First add a record or two into the Music table. The Insert command needed is shown in the command file for this presentation. Then run the command above. Marge Hohly

SQL DESCRIBE DESCRIBE <table name>; DESCRIBE employees; Try the last statement. How many rows are returned? 20 Note: you only see 10 records if you did not change the display option on APEX prior to running this command. Marge Hohly

Inserting Data INSERT INTO tablename (column1, column2,....) VALUES(value1,value2,...); Remember character data needs to be enclosed in single quotes. Slide 8: Tell Me /Show Me – Using the INSERT command, you can add a row … Ask what would happen if you tried to insert a row with values (9, ‘ERIC CLAPTON’, ‘ROCK’). Answer: You would get an error because there is already a row with musicid = 9. Musicid is the primary key of the table and must be unique. Refer to the handout of basic SQL commands and populate the table. This is part of your homework assignment. Put in a record of your own See the example In the command file for this presentation. Marge Hohly

Insert Data Note the data types for each column Inserting data into the table. Since the table is empty all fields need to be populated, so column names can be omitted INSERT INTO music VALUES (10,'Marge Hohly','Folk'); This will insert one record into the table Next display the contents of the table to view the data SELECT * FROM music; Point out format and structure: Reserved words all caps Fields (attributes) lower case End with ; Single quotes = text data No quotes = numeric data Marge Hohly

Insert Data into table INSERT INTO <table name> VALUES (value 1, value 2, value 3, etc); INSERT INTO music VALUES (10,'Marge Hohly','Folk'); Ask what would happen if you tried to insert a row with values (9, ‘ERIC CLAPTON’, ‘ROCK’). Answer: You would get an error because there is already a row with musicid = 9. Musicid is the primary key of the table and must be unique. Marge Hohly

Typical error messages The following statement has a spelling error: SELCT * FROM employees; The error message is:       ORA-00900: invalid SQL statement The following statement incorrectly names the table employee instead of employees: SELECT * FROM employee; The error message is:       ORA-00942: table or view does not exist Run the correct statement. SELECT * FROM employees; Slide 1: Anatomy of a SQL Statement What to Watch For This may be a student's first time using SQL. Insist on a standard for coding statements and demonstrate it early in this lesson. If you want statements of separate lines, show students your standard. At the beginning, students will be frustrated when their queries don't return what they expected. It is helpful to code several incorrect SQL queries and demonstrate what error messages are returned. This will help students become more independent and help reduce the "it doesn't work" statements. For instance: The following statement has a spelling error: SELCT * FROM employees The error message is: ORA-00900: invalid SQL statement The following statement incorrectly names the table employee instead of employees: SELECT * FROM employee The error message is: ORA-00942: table or view does not exist Marge Hohly

Subset of data WHERE clause SELECT <column name 1, column name 2, etc.> FROM <table name> WHERE <condition>; SELECT first_name, last_name, salary FROM employees WHERE salary > 5000; 13.1.5 Explain that the <condition> often takes the form of column name + operator (=, >, <, IS NULL, IS NOT NULL, etc.)." Marge Hohly

ALTER table structure ALTER TABLE <table name> ADD (<new_column_name> <data type>); Try to modify the structure of the MUSIC table Add a column (which you will misspell) COUNTRI instead of COUNTRY). ALTER TABLE my_music ADD (countri ); You may want to demonstrate this on your computer if you can share your screen with the students. Add a column to the MUSIC table using the ALTER TABLE command, -- but misspell the column (e.g., COUNTRI instead of COUNTRY). Slide 2: What Will I Learn? Add Column: Mention that this type of change to a table is different from adding or removing data. You’re changing the structure. This is called DDL (data definition language -- you’ll learn more about this in SQL). it’s good to mention this at this point so that, when students hear it later, it will be familiar. Marge Hohly

Deleting a column from a table ALTER TABLE <table name> DROP COLUMN <column_name>; Now delete the column (COUNTRI) you just added. Display the structure first to show misspelled column. ALTER TABLE my_music DROP COLUMN countri; Marge Hohly

Deleting a row DELETE from <table name> WHERE <column_name> = 'some value' ; DELETE from music WHERE musicid = 10; DELETE from music WHERE type = ‘Folk’; Point out that numbers do not require quotes around them (example: 10), but text does (example: ‘ERIC CLAPTON’). Note the case of the value of the table data. Mixed case, all upper case Marge Hohly

Database Facts Currently 20% of the world's data resides in relational DBMSs. In the next two years, databases are expected to grow larger than 100 terabytes. A database this big would be able to store 100,000 copies of the Encyclopedia Britannica or 200,000 hours of music or about 10 billion web pages. The top 10 world's largest databases using the Oracle DBMS are: France Telecom, 29.2TB -- a communications company (a TB is a terabyte equivalent to 1,000 gigabytes) Amazon.com with, 13 TB -- selling books and merchandise The Claria Corporation,12TB -- Internet behavioral marketing company tracking Internet user behavior Database facts are a bit old so they should be updated. Marge Hohly

Oracle Facts One of Oracles first customers was the CIA, for which they created a relational database management system. Much of Oracles early success was owed to picking up IBM as a major customer. 2nd half of the ‘90s was spend retooling Oracle products in line with that online strategy (the internet) Ellison said in 1998: “If the internet turns out not to be the future of computing, we’re toast. But if it is, we’re golden.” Oracle was the first enterprise software to fully embrace the Java Programming language back in 1998. Oracle has purchased 57 different companies in the last 5 years. The buying frenzy was launched with the $10.3 billion acquisition of PeopleSoft in 2005, which put Oracle squarely in the ERP software fray. Marge Hohly

Oracle Facts The latest mega-purchase: Sun Microsystems, a $7.4 billion acquisition due to close this year if regulators don't object. Oracle today now has 345,000 customers worldwide. Oracle employs more than 73,201 people around the globe. Marge Hohly

Application Express SQL editor The SQL course will use the three following sets of database tables for examples and practice exercises. Oracle tables: COUNTRIES, REGIONS, DEPARTMENTS, EMPLOYEES, JOBS, JOB_HISTORY AND JOB_GRADES DJs on Demand database tables: D_CDS, D_PACKAGES, D_TYPES, D_THEMES, D_CLIENTS, D_VENUES, D_SONGS, D_TRACK_LISTINGS, D_PARTNERS, D_EVENTS, D_PLAY_LIST_ITEMS, D_JOB_ASSIGNMENTS Global Fast Foods database tables: F_CUSTOMERS, F_REGULAR_MENUS, F_PROMOTIONAL_MENUS, F_SHIFTS, F_STAFFS, F_FOOD_ITEMS, F_ORDERS, F_ORDER_LINES, F_SHIFT_ASSIGNMENTS Print out these tables for your reference when using the Application Express editor These tables are available on the Student Resource web page for this class Marge Hohly

Review the tables There are six properties of tables in a relational database: Property 1: Entries in columns are single-valued. Property 2: Entries in columns are of the same kind. Property 3: Each row is unique. Property 4: Sequence of columns is insignificant. Property 5: Sequence of rows is insignificant. Property 6: Each column has a unique name. Marge Hohly

Categories of SQL Statements Data manipulation language (DML) statements Begin with INSERT, UPDATE, DELETE, or MERGE Used to modify the table by entering new rows, changing existing rows, or removing existing rows. Data definition language (DDL) statements set up, change, and remove data structures from the database. The keywords CREATE, ALTER, DROP, RENAME, and TRUNCATE begin DDL statements. Transaction control (TCL) statements are used to manage the changes made by DML statements. Changes to the data are executed using COMMIT, ROLLBACK, and SAVEPOINT. TCL changes can be grouped together into logical transactions. Data control language (DCL) keywords GRANT and REVOKE are used to give or remove access rights to the database and the structures within it. Data retrieval -- Check the balance of a checking/savings account. Data manipulation -- Change an email address that the bank uses to notify a customer that an online bank statement has been posted. Data definition -- Create a new online account; the bank can alter data in an account or drop an account that is delinquent. Transaction control language -- Arrange to have a bill paid online and then decide later to change the date originally set for payment. Online bill paying usually has a SUBMIT(COMMIT) option after several transactions have been entered. Data control language -- The bank can revoke an overdrawn account or a credit card issued for failure to make the payment obligations. The bank can grant other users access to an account if requested by the owner of the account. Marge Hohly

Questions The Fast Foods database consists of how many tables? ____ tables How is the F_SHIFTS table related to the F_STAFFS table? What are the names of the columns in the F_CUSTOMERS table? How many rows of data have been entered in the F_PROMOTIONAL_MENUS table? In the F_FOOD_ITEMS table, column _________ is a foreign-key column. What table and column is this key referencing? List the primary key to foreign key relationships required to go from the F_SHIFTS table to the F_REGULAR_MENUS table. Which table(s) contain null values? 1. The Global Fast Foods database consists of how many tables? _9___tables 2. How is the F_SHIFTS table related to the F_STAFFS table? The code column in F_SHIFTS to the code column in F_SHIFT_ASSIGNMENTS to id in F_SHIFT_ASSIGNMENT to id in F_STAFFS 3. What are the names of the columns in the F_CUSTOMERS table? id, first_name, last_name, address, city, state, zip, phone_number 4. How many rows of data have been entered in the F_PROMOTIONAL_MENUS table? 2 5. In the F_FOOD_ITEMS table, column _regular_code__ is a foreign-key column. What table and column is this key referencing? F_REGULAR_MENUS code column 6. List the primary key to foreign key relationships required to go from the F_SHIFTS table to the F_REGULAR_MENUS table. In Application Express SQL Workshop view, click the Tables icon and then click the magnifying glass icon for the table you want to access. Below the Table Summary information is listed the Foreign Keys (Tables that reference...) and Foreign Keys (Tables.....references). Step through each table using this feature with students. For this exercise the table references starting with F_SHIFTS to F_REGULAR_MENUS is:  f_shifts to f_shift_assignments to f_staffs to f_orders to f_customers then from f_orders to f_order lines to f_food_items to f_promotional_menus and f_regular_menus. 7. Which table(s) contain null values? F_FOOD_ITEMS and F_STAFFS Students can use Application Express and "SELECT *  FROM tablename;" to view each table in the Fast Foods database. Using the Fast Foods database, students will answer the Fast Foods Tables Activity. The objective of this activity is to familiarize students with the basic structure of a database table and to introduce the Fast Foods tables they will be using. Students should be able to relate primary to foreign keys and identify and name examples of column, row, and field. Reinforce the importance of being able to easily relate tables of information together. Marge Hohly

KEYWORD, CLAUSE, STATEMENT Throughout this course, the words keyword, clause, and statement are used as follows: A keyword refers to an individual SQL element. For example, SELECT and FROM are keywords. A clause is a part of a SQL statement. SELECT employee_id, last_name, .... is a clause. A statement is a combination of two or more clauses. SELECT * FROM employees; is a SQL statement. 16.5.x Marge Hohly

Selection vs. Projection SELECT salary FROM employees WHERE last_name like ‘Smith’; Selection (row) Projection (column) ID First_name Last_name salary 10 John Doe 4000 20 Jane Jones 3000 30 Sylvia Smith 5000 40 Hai Nguyen 6000 Slide 7: Tell Me /Show Me – A SELECT statement can do the following: Projection- The capability in SQL to choose the columns in a table that you want returned from a query Selection- The capability in SQL to choose the rows in a table returned from a query Marge Hohly

Join Slide 8: Tell Me /Show Me – Join: Used to bring together data that is stored … Join- Display data from two or more related tables Marge Hohly

SELECT statement SELECT statements can provide the same information depending on how they are written Example: SELECT * FROM d_songs; SELECT id, title, duration, artist, type_code FROM d_songs; Slide 9: Tell Me /Show Me – Selecting all Columns Take time for students to practice each new keyword. Warn students that sometimes doing a SELECT * FROM table can take a long time to return the data. It all depends on the number of rows stored in that particular table. Remember, Oracle tables can store millions of rows of data. Break this content into show and practice. Explain one SQL keyword/statement at a time, and then have the students practice. Slide 10: Tell Me / Show Me – Selecting all Columns (continued) Demonstrate coding conventions to the students. All queries can be in lowercase, but for clarity and ease of reading, you may want to have keywords typed in UPPERCASE. It makes finding student mistakes easier. Also make sure that each keyword starts on a new line, as this further eases reading and de-bugging of the code students are producing. All examples on the slides have a semicolon after each statement. Oracle Application Express does not require this syntax, but other Oracle SQL Interfaces do, so we have included them in the courseware. It may be worth mentioning or demonstrating semicolon not being required in Oracle Application Express, but other Oracle tools. Marge Hohly

SELECTION SELECT * FROM employees WHERE department_id = 60; SELECT * FROM employees WHERE salary > 10000; Selection is a selection of rows, all fields Marge Hohly

Projections A subset of columns SELECT first_name, last_name, salary FROM employees; SELECT id, title, artist FROM d_songs; Marge Hohly

Arithmetic Expressions Create expressions with number and date data by using arithmetic operators. Operator Description + Add - Subtract * Multiply / Divide 5(5*6) + 20 SELECT last_name, salary, 12*salary+100 rewrite as 12*(SALARY + 100) FROM employees; Marge Hohly

Operator Precedence () ^ * / + - Operator Precedence Multiplication and division take priority over addition and subtraction. Operators of the same priority are evaluated from left to right. Parentheses are used to force prioritized evaluation and to clarify statements. Remember: Please excuse my dear aunt Sally () ^ * / + - Slide 16: Tell Me / Show Me – Using Arithmetic Operators If operators within an expression are of the same priority, then evaluation is done from left to right. Explain using the following example: Operators that appear in the same group have the same precedence. Which means in the multiplicative group that multiplication is done before division which is done before percentage. In the additive group, addition is done before subtraction. You can always use parentheses to force the expression within parentheses to be evaluated first. In the example 5(5*6) + 20, the expression (5*6) is processed first, that value (30) is multiplied by 5 to equal 150, and then 20 is added to the result. Rewrite the SQL statement shown to produce the results shown in the Operator Precedence table. SELECT last_name, salary, 12*salary+100 rewrite as 12*(SALARY + 100) FROM employees; Marge Hohly

Rewrite in order of precedence You want to calculate the annual salary if the employee received $100 raise each month Revise the following statement in the correct order of precedence to get the desired results Run each example in the editor SELECT last_name, salary, 12*salary+100 FROM employees; rewrite as 12*(SALARY + 100) Marge Hohly

What is null? If a row lacks the data value for a particular column, that value is said to be null, or to contain a null. A null is a value that is unavailable, unassigned, unknown, or inapplicable. A null is not the same as zero. Zero is a number. A null is not a space. Space is a character. Slide 20: Tell Me / Show Me – Null Values NULL- A value that is unavailable, unassigned, unknown, or inapplicable Marge Hohly

Null Values in Arithmetic Expressions SELECT last_name, salary, commission_pct, salary*commission_pct FROM employees; SALARY COMMISSION_PCT SALARY*COMMISSION_PCT 2500 (null) 10500 .2 2100 11000 .3 3300 8600 1720 7000 .15 1050 Arithmetic with null results in null. Marge Hohly

Practice SELECT * FROM d_songs; SELECT id, title, duration, artist, type_code FROM d_songs; SELECT id, title, artist, FROM d_songs; SELECT last_name, salary, salary – 300 FROM employees; SELECT last_name, salary, salary * 1.05 FROM employees; Demonstrate coding conventions to the students. All queries can be in lowercase, but for clarity and ease of reading, you may want to have keywords typed in UPPERCASE. It makes finding student mistakes easier. Warn students that sometimes doing a SELECT * FROM table can take a long time to return the data. It all depends on the number of rows stored in that particular table. Remember, Oracle tables can store millions of rows of data. SELECT id, title, artist, FROM d_songs; Note error: This will not run with the , at the end of the field list. If it is removed the command will run correctly. Marge Hohly

Column Alias Renames a column heading Is useful in naming columns of derived values Immediately follow the column name Uses optional AS keyword between the column name and alias Required double quotation marks if it contains spaces or special characters or is case sensitive Marge Hohly

Using Aliases NAME SALARY Annual Salary Whalen 4400 52800 Hartstein SELECT last_name name, salary AS Salary, salary*12 “Annual Salary” FROM employees; NAME SALARY Annual Salary Whalen 4400 52800 Hartstein 13000 156000 Fay 6000 72000 Explain the purpose of an alias. Your boss would probably not recognize what a column name such as DEPT_NO means. It would be your job to create a report with the column name "Department Number " instead. Explain that double quotation marks are required for aliases longer than one word or when the format of the alias is anything other than the default uppercase name (e.g., Department Name, or department, or dept.) Explain that the pipe (|) means OR in this example. The pipe key is the caps lock position above the backslash (\) on most keyboards. Marge Hohly