Looking for a Tutor Near You?

Post Learning Requirement »
x
x

Direction

x

Ask a Question

x

Hire a Tutor

PPT On Fundamental About Oracle Database

Loading...

Published in: Oracle Training
3,923 Views

This PPT will present the Fundamental about Oracle Database.

Eyad / Abu Dhabi

15 years of teaching experience

Qualification: Computer Science Graduate

Teaches: Arabic, C# (C Sharp), Computer Science, .Net, Oracle

Contact this Tutor
  1. Oracle Database 10g: SQL Fundamentals I
  2. Retrieving Data Using the SQL SELECT Statement
  3. Objectives After completing this lesson, you should be able to do the following: List the capabilities of SQL SELECT statements Execute a basic SELECT statement Differentiate between SQL statements and iSQL*PIus commands 1-3
  4. Capabilities of SQL SELECT Statements Projection Table 1 Table 1 1-4 selection Table 1 Join Table 2
  5. Basic SELECT Statement SELECT { [DISTINCT] columnl expression [alias] , • • • } table; FROM SELECT identifies the columns to be displayed FROM identifies the table containing those columns 1-5
  6. All SELECT FROM Selecting departments ; DEPARTMENT ID 20 50 I ICI B rows selected. 1-6 DEPARTMENT NAME Administration Marketing Shipping Sales Executive Accounting Contracting Columns MANAGER ID 124 1 413 I rjr-l 205 LOCATION ID 171--10 1500 1400 171--10 171.10 1700
  7. Selecting Specific Columns SELECT department id, FROM departments ; DEPARTMENT ID B rows selected. 1-7 location id LOCATION ID
  8. Writing SQL Statements SQL statements are not case-sensitive. SQL statements can be on one or more lines. Keywords cannot be abbreviated or split across lines. Clauses are usually placed on separate lines. Indents are used to enhance readability. In iSQL*PIus, SQL statements can optionally be terminated by a semicolon (;). Semicolons are required if you execute multiple SQL statements. In SQL*pIus, you are required to end each SQL statement with a semicolon 1-8
  9. Column Heading Defaults iSQL*Plus: Default heading alignment: Center Default heading display: Uppercase SQL*Plus: Character and Date column headings are left- aligned Number column headings are right-aligned Default heading display: Uppercase 1-9
  10. Arithmetic Expressions Create expressions with number and date data by using arithmetic operators. Operator 1-10 Description Add Subtract Multiply Divide
  11. Using Arithmetic Operators SELECT last name, FROM employees ; LAST NAME 20 rows selected. 1-11 salary , salary + 300 SALARY SALARY+300
  12. Operator Precedence SELECT FROM Kochhar De Haan last name , employees ; LAST NAME 20 rows selected. SELECT last name, FROM employees ; LAST NAME Kochhar De Haan 20 rows selected. 1-12 salary , SALARY salary , SALARY 12 * salary+100 12*SALARY+100 17000 17000 12* (salary+100) I nor-I
  13. Defining a Null Value A null is a value that is unavailable, unassigned, unknown, or inapplicable. A null is not the same as a zero or a blank space. SELECT last name, job id, salary, commission pct FROM employees ; LAST NAME Koc.hhar Zlotkey Abel Gietz 20 rows selected. 1-13 JOB ID PRES SA MAN REP SA REP AC ACCOUNT 17000 2 .3 .2
  14. Null Values in Arithmetic Expressions Arithmetic expressions containing a null value evaluate to null. SELECT last name, 12 *salary *conunission pct FROM employees ; xocppsL. rvef Zlotkey Abel Gietz 20 rows selected. 1-14
  15. Defining a Column Alias A column alias: Renames a column heading Is useful with calculations Immediately follows the column name (There can also be the optional AS keyword between the column name and alias.) Requires double quotation marks if it contains spaces or special characters or if it is case- sensitive 1-15
  16. Using Column Aliases SELECT FROM Kochhar De Haan 20 rows selected. last name AS employees ; NAME name , cormnission pct comm COMM SELECT last name "Name" FROM employees ; Name Kochhar De Haan 20 rows selected. 1-16 salary *12 "Annual Annual Salary Salar
  17. Concatenation Operator A concatenation operator: Links columns or character strings to other columns Is represented by two vertical bars (Il) Creates a resultant column that is a character expression SELECT FROM KingAD_PRES De I-laanACI VP 20 rows selected. 1-17 last nam I I 0b id AS "Employees " employees ; Employees
  18. Literal Character Strings A literal is a character, a number, or a date that is included in the SELECT statement. Date and character literal values must be enclosed by single quotation marks. Each character string is output once for each row returned. 1-18
  19. Using Literal Character Strings SELECT last name I I ' is a ' I I job AS "Employee Details " FROM employees ; Employee Details King is a AD PRES Kochhar is a AD VP De Haan is a AD VP is a IT PROG Ernst is a IT PROG is a IT PROG Mourgos is a ST MAB] Rajs is a ST CLERK 20 rows selected. 1-19 id
  20. Alternative Quote (q) Operator Specify your own quotation mark delimiter Choose any delimiter Increase readability and usability SELECT de artment name I I q' [ , it's assigned I I manager id AS "Department and FROM departments ; Administration, it's assigned manager ID: 21-T-I Marketing, it's assigned rnanager ID. 201 Shipping, it's assigned tmanager ID: 124 B rows selected. 1-20 Manager Id : Manager " Department and Manager
  21. Duplicate Rows The default display of queries is all rows, including duplicate rows. SELECT department id FROM employees ; DEPARTMENT ID 20 rows selected. SELECT DISTINCT epartment id FROM employees ; DEPARTMENT ID B rows selected. 1-21 gr-l 2 20 50
  22. SQL and iSQL*PIus Interaction ORACLE Internet browser iSQL*Plus commands Client 1-22 SQL statements Query results Formatted report Oracle server
  23. SQL Statements Versus iSQL*PIus Commands SQL A language ANSI standard Keyword cannot be abbreviated Statements manipulate data and table definitions in the database 1-23 iSQL*Plus An environment Oracle-proprietary Keywords can be abbreviated Commands do not allow manipulation of values in the database Runs on a browser Centrally loaded; does not have to be implemented on each machine
  24. Overview of iSQL*Plus After you log in to iSQL*PIus, you can: Describe table structures Enter, execute, and edit SQL statements Save or append SQL statements to files Execute or edit statements that are stored in saved script files 1-24
  25. Logging In to iSQL*PIus From your browser environment: http:\$esslinü5:556ü\isqlplus\ Address Classroom Support Links éjGlobal Education Links Cf.-lass Accounts! 0RAcL-e Oracle Online Evaluations * Indicates required field Username * Password Connect Identifier 1-25 oral
  26. iSQL*Plus Environment 8 a 9 ORACLE Workspace Enter sac, PIJSr-aL and saL*PIus statements. 1-26 7 Loqout Prefererłces Workspace Connected as ORA1@T6 Clear 6 V: V:
  27. Displaying Table Structure Use the iSQL*PIus DESCRIBE command to display the structure of a table: DESC [RIBE] tablename 1-27
  28. Displaying Table Structure DESCRIBE employees Name Type 1-28
  29. Interacting with Script Files 0RAcce Workspace Enter sac, PUSU and saL*PIus statements. SELECT last name, hire date , Logout Preferences Workspace Connected as ORA1@T6 Clear sal ary FROM Execute 1-29 employees ; Load Script 2 Save Script Cancel
  30. Interacting with Script Files Save As Save in: History EDCDR17P1 My Network. P.. 1-30 a TEMP - basesvcs.txt hwurl.err = hwurl.txt madsvcs.txt ntldr o postinst.bat RealPlayer-lag. txt RNS , htm - rnlog,txt snapcons.txt staturl.err staturl,txt tnsupd. bat tnsupd log updFiles. File name: Save as type: emp_data.sql All Files Save Cancel
  31. Interacting with Script Files 0RAcL-e iSQL*P1u— Workspace Enter sac, PI-ISU and saL*PIus statements. Logout Preferences Workspace C.onnected as ORA1@T6 Clear Execute 1-31 Load Script Save Script Cancel
  32. Interacting with Script Files 0RAcL-e Load Script Enter a URL, or a path and file name of the script to load. URL File D: data. sql Preferences Workspace Connected as ORA1@T6 Cancel 2 Workspace I History mae . NI llQhE ruene6. Logout Preferences Load 3 1-32
  33. iSQL* History Plus History Page Workspace Histoly Connected as ORA1@T6 Script history is not available for previous sessions. 3 The scripts listed are for the current session. Select scripts and ... Select All I Select Bdr-•ne Select Script Delete Load 2 r r r r r r r r SELECT DISTINCT department_id FRON,I employees. SELECT department_id FROM etnployees: SELECT department _ name Il ' Il it's assigned rnanager ID: X.' Il manager SELECT last SELECT last SELECT last SELECT last SELECT last SELECT last SELECT last name Il I is a 'Il job id AS "Employee Details" FROM employees. narne Il job _ id AS "Employees" FROM ernployees, name 'INarne", 12 * salary "Annual Salary" FROM ernployees, name AS narne. commission_pct AS comm FROM employees: name. 12 * salary * commission pct FROM employees: narne. job_id. salary, commission _ pct FROM employees: narme. salary, 12 * (salary + •ICICI) FROM ernployees: 1-33
  34. iSQL*Plus History Page 0RAcce Workspace Enter sac, PUSaL and saL*PIus statements. SELECT last name, 12 * salary * commission pct FROM employees; SELECT last name "Narne", 12 * salary "Annual Salary" FROM employees; 3 Laqr-ll-lt Preferences Workspace Connected as ORA1@T6 Clear 4 Execute 1-34 Load Script Save Script Cancel
  35. Setting iSQL*PIus Preferences ORACLE (D I-ago-it Prefer nce.s 'vVorkspa 2 • Interface Configuration System Configuration Script o Formatting Script o Execution o Database Administration Interface Configuration Configure settings that affect the iSOL*PIus user intetface. History Size Set the number of scripts displayed in the script history. Scripts •l Cl Input Area Size Set the size of the script input area. Width 70 Il-I Output Location Help 3 Change Password 1-35
  36. Setting the Output Location Preference • Interface Configuration System Configuration o Script Formatting o Script Execution o Database Administration Change Password 1-36 2 Interface Configuration Configure settings that affect the iSOL*PIus user interface. History Size Set the number of scripts displayed in the script history. Scripts Input Area Size Set the size of the script input area. VVidth 70 Output Location Set where script output is displayed. Below Input Area save to File Printable output in new browser window Printable output in same browser window
  37. Summary In this lesson, you should have learned how to: Write a SELECT statement that: Returns all rows and columns from a table Returns specified columns from a table Uses column aliases to display more descriptive column headings Use the iSQL*PIus environment to write, save, and execute SQL statements and iSQL*PIus commands SELECT { [DISTINCT] columnl expression [alias] , • • • } FROM table; 1-37
  38. Practice 1 : Overview This practice covers the following topics: Selecting all data from different tables Describing the structure of tables Performing arithmetic calculations and specifying column names Using iSQL*PIus 1-38