SQL Introduction Chapter 7, sections 1 & 4. Introduction to SQL. Introduction to SQL. Introduction to SQL



Similar documents
Chapter 1. Writing Basic. SQL Statements

Producing Readable Output with SQL*Plus

Oracle 10g PL/SQL Training

Oracle Database: Introduction to SQL

Database Design. Marta Jakubowska-Sobczak IT/ADC based on slides prepared by Paula Figueiredo, IT/DB

SQL*Plus User s Guide and Reference

Oracle Database: Introduction to SQL

Managing Objects with Data Dictionary Views. Copyright 2006, Oracle. All rights reserved.

Oracle Database: Introduction to SQL

Data Models and Database Management Systems (DBMSs) Dr. Philip Cannata

Retrieving Data Using the SQL SELECT Statement. Copyright 2006, Oracle. All rights reserved.

Oracle Database 11g SQL

Subqueries Chapter 6

Displaying Data from Multiple Tables. Chapter 4

Oracle Database: SQL and PL/SQL Fundamentals

Database 10g Edition: All possible 10g features, either bundled or available at additional cost.

Oracle/SQL Tutorial 1

Displaying Data from Multiple Tables

Oracle Database 10g: Introduction to SQL

Uploads from client PC's to mercury are not enabled for security reasons.

Oracle SQL. Course Summary. Duration. Objectives

Objectives of SQL. Terminology for Relational Model. Introduction to SQL

ORACLE 10g Lab Guide

5. CHANGING STRUCTURE AND DATA

A basic create statement for a simple student table would look like the following.

SQL Simple Queries. Chapter 3.1 V3.0. Napier University Dr Gordon Russell

MONASH UNIVERSITY. Faculty of Information Technology

Database Programming with PL/SQL: Learning Objectives

Oracle Database: SQL and PL/SQL Fundamentals

CHAPTER 2 DATABASE MANAGEMENT SYSTEM AND SECURITY

3.GETTING STARTED WITH ORACLE8i

Using Multiple Operations. Implementing Table Operations Using Structured Query Language (SQL)

Relational Algebra. Query Languages Review. Operators. Select (σ), Project (π), Union ( ), Difference (-), Join: Natural (*) and Theta ( )

Oracle Database 12c: Introduction to SQL Ed 1.1

RDBMS Using Oracle. Lecture Week 7 Introduction to Oracle 9i SQL Last Lecture. kamran.munir@gmail.com. Joining Tables

Setting Up ALERE with Client/Server Data

Oracle Database: SQL and PL/SQL Fundamentals NEW

Database Query 1: SQL Basics

SQL, PL/SQL FALL Semester 2013

Teach Yourself InterBase

KB_SQL SQL Reference Guide Version 4

Oracle Database: Develop PL/SQL Program Units

ATTACHMENT 6 SQL Server 2012 Programming Standards

Oracle Database 10g: Program with PL/SQL

Course 20461C: Querying Microsoft SQL Server Duration: 35 hours

D61830GC30. MySQL for Developers. Summary. Introduction. Prerequisites. At Course completion After completing this course, students will be able to:

Course ID#: W 35 Hrs. Course Content

Oracle Database 10g Express

Oracle Database: SQL and PL/SQL Fundamentals NEW

Aggregating Data Using Group Functions

Querying Microsoft SQL Server

COURSE OUTLINE UCLA EXTENSI ON MGMNT X

Structured Query Language (SQL)

Using AND in a Query: Step 1: Open Query Design

Examine the structure of the EMPLOYEES table: EMPLOYEE_ID NUMBER Primary Key FIRST_NAME VARCHAR2(25) LAST_NAME VARCHAR2(25)

2. Oracle SQL*PLUS Winter Some SQL Commands. To connect to a CS server, do:

CSC 443 Data Base Management Systems. Basic SQL

9.1 SAS. SQL Query Window. User s Guide

1 File Processing Systems

Database Access from a Programming Language: Database Access from a Programming Language

Database Access from a Programming Language:

REPORT GENERATION USING SQL*PLUS COMMANDS

Oracle Database: Program with PL/SQL

Saskatoon Business College Corporate Training Centre

History of SQL. Relational Database Languages. Tuple relational calculus ALPHA (Codd, 1970s) QUEL (based on ALPHA) Datalog (rule-based, like PROLOG)

Using Microsoft SQL Server A Brief Help Sheet for CMPT 354

Oracle For Beginners Page : 1

SQL Databases Course. by Applied Technology Research Center. This course provides training for MySQL, Oracle, SQL Server and PostgreSQL databases.

Oracle Database: Program with PL/SQL

1. INTRODUCTION TO RDBMS

Oracle Database: Program with PL/SQL

Querying Microsoft SQL Server 20461C; 5 days

Mini User's Guide for SQL*Plus T. J. Teorey

Database System Architecture & System Catalog Instructor: Mourad Benchikh Text Books: Elmasri & Navathe Chap. 17 Silberschatz & Korth Chap.

Oracle Database: Program with PL/SQL

Backing up and restoring HP Systems Insight Manager 6.0 or greater data files in a Windows environment

Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.

Toad for Oracle 8.6 SQL Tuning

Training Guide. PL/SQL for Beginners. Workbook

SQL. Short introduction

Querying Microsoft SQL Server Course M Day(s) 30:00 Hours

Basic SQL Server operations

Monitoring Oracle Enterprise Performance Management System Release Deployments from Oracle Enterprise Manager 12c

SQL> SELECT ename, job, sal Salary. 1.4.Will the SELECT statement execute successfully? True/False

Copying data from SQL Server database to an Oracle Schema. White Paper

Chapter 2 Database System Concepts and Architecture

Lab 2: PostgreSQL Tutorial II: Command Line

USING MYWEBSQL FIGURE 1: FIRST AUTHENTICATION LAYER (ENTER YOUR REGULAR SIMMONS USERNAME AND PASSWORD)

Appendix A Practices and Solutions

DBMS Questions. 3.) For which two constraints are indexes created when the constraint is added?

Using TimesTen between your Application and Oracle. between your Application and Oracle. DOAG Conference 2011

Oracle. Brief Course Content This course can be done in modular form as per the detail below. ORA-1 Oracle Database 10g: SQL 4 Weeks 4000/-

ORACLE 9I / 10G / 11G / PL/SQL COURSE CONTENT

Duration Vendor Audience 5 Days Oracle End Users, Developers, Technical Consultants and Support Staff

BCA. Database Management System

Create!form Folder Monitor. Technical Note April 1, 2008

Oracle For Beginners Page : 1

Triggers & Packages. {INSERT [OR] UPDATE [OR] DELETE}: This specifies the DML operation.

MOC QUERYING MICROSOFT SQL SERVER

Transcription:

SQL Introduction Chapter 7, sections 1 & 4 Objectives To understand Oracle s SQL client interface Understand the difference between commands to the interface and SQL language. To understand the Oracle server environment, and how to access that environment. Outline SQL what is it? Basic functions DDL coomands DML commands Basic Queries System Catalog Querying User_Tables Querying All_Tables SQLPlus commands SQLPlus installation SQL meets ideal database language requirements: SQL is relatively easy to learn Basic command set has vocabulary of less than 100 words Nonprocedural a 4 th Generation Language Specifies what you want, not how to retrieve it. American National Standards Institute (ANSI) prescribes a standard SQL Several SQL dialects exist 1 2 SQL coverage fits into two categories: Data definition (DDL) Create database objects and define rights to those objects Data manipulation (DML) To retrieve, insert, update, and delete data. SQL DML Commands SQL DDL Commands 3 4

Listing Table Rows Using the Select Command SELECT Used to list contents of table Syntax: SELECT column, column, FROM user.tablename; SELECT * FROM user.tablename; The column list represents one or more attributes, separated by commas Asterisk can be used as wildcardcharacterto list all attributes Useful to view the data in a table before and again after changes/additions have been made. Examples: SELECT EMPNO, ENAME FROM CS275.EMP; SELECT * FROM CS275.EMP; SELECT DNAME, LOC FROM CS275.DEPT; 5 6 Selecting Rows with Conditional Restrictions Basic Select partial table contents by placing restrictions on rows to be included in output Add conditional restrictions to SELECT statement, using WHERE clause Syntax: SELECT columnlist FROM tablelist [ WHERE conditionlist] ; Partial Listing of Table Contents SELECT <column(s)> FROM <table name> WHERE <conditions>; Example: SELECT ENAME, JOB WHERE DEPTNO = 20; ENAME JOB ---------- --------- SMITH CLERK JONES MANAGER SCOTT ANALYST ADAMS CLERK FORD ANALYST 8 7

The where clause selects rows based a logical comparison operator given two operands. SELECT EMPNO, ENAME WHERE SAL >= 2500; EMPNO ENAME ------- ------- 7566 JONES 7698 BLAKE 7788 SCOTT 7839 KING 7902 FORD 9 10 SELECT DEPTNO, DNAME FROM DEPT WHERE LOC!= 'NEW YORK ; SELECT EMPNO, ENAME, DEPTNO WHERE HIREDATE >= '01-JAN-85 ; DEPTNO DNAME ------- ---------- 20 RESEARCH 30 SALES 40 OPERATIONS EMPNO ENAME DEPTNO -------- ---------- ---------- 7788 SCOTT 20 7876 ADAMS 20 11 12

The user s data dictionary The user s data dictionary Looking at your environment Displays tables for current logon >select table_name from user_tables; >select * from tab; Displays other objects for current logon >select * from user_objects; Looking at a table s data dictionary with a SQLPlus Command sqlplus> describe user.<tablename> Looking at objects and tables in the database where you are not the owner. Displays tables or objects >select table_name from all_tables; >select * from all_objects; To display tables or objects from a specific account where you have read access rights >select table_name from all_tables where owner = CS275 ; 13 14 Oracle Interface - Basic SQLPLUS Review Basic SQLPlus Interface Getting on the Data Base SQLPLUS Programs->Oracle->Appl.Dev.->SQL plus Vista: Run as Administrator Logon: Name/password/database Name: FirstName * Password:L# Database CITORACLE & CITORACLE_W Logging off EXIT * duplicates need to add the first character of the last name MENU System File: Open, Save, Spool Open will set your local directory path Editing Invoking the editor Temp file afied.buf Saving from the editor Options -> Environment Pagesize Linesize These also have command line alternatives 15 16

Basic SQLPLUS Commands Basic SQLPLUS >RUN [/] Executes the sql statement in the buffer >LIST [l] Displays current statement in the buffer >DESCRIBE Displays attribute information for a table >EDIT invokes host operating system text editor >EXIT terminates the client session Scripting SQL from TEXT FILES >GET <filename> Retrieves SQL statement from a file and puts it into the active buffer. >SAVE <filename> Saves the active SQL statement in named file >START <filename> Allows execution of multiple SQL statements from a file >SPOOL <filename> Saves session history in named file 17 18 Working off-site - SQLPlus Summary Installing the SQL Client on your own machine. Must have WinXP, Vista, or Win7, but higher versions than the limited home version. Download the directions & file from our website resource page. Connecting to the Database. You will first need to put the tnsnamesfile into your Oracle home. This file will be given out in class or you may get it in the Lab. Open the SQL Client and logon using the Wireless database connection. For Vista, use Run as an administrator SQL commands can be divided into two overall categories: Data definition language commands Data manipulation language commands The basic SELECT statement Where clause Using the SQLPlus environment Basic SQLplus commands Setting the environment. Creating and using script files 19 20