ORACLE Using ORACLE 8 SQL using ORACLE 8 PL/SQL using ORACLE 8.

Slides:



Advertisements
Similar presentations
Data Definition Language (DDL)
Advertisements

Database Security and Auditing: Protecting Data Integrity and Accessibility Chapter 8 Application Data Auditing.
Database Security and Auditing: Protecting Data Integrity and Accessibility Chapter 8 Application Data Auditing.
Oracle9i Database Administrator: Implementation and Administration 1 Chapter 12 System and Object Privileges.
Let’s try Oracle. Accessing Oracle The Oracle system, like the SQL Server system, is client / server. For SQL Server, –the client is the Query Analyser.
Introduction to Structured Query Language (SQL)
System Administration Accounts privileges, users and roles
1 Table Alteration. 2 Altering Tables Table definition can be altered after its creation Adding columns Changing columns’ definition Dropping columns.
A Guide to SQL, Seventh Edition. Objectives Understand the concepts and terminology associated with relational databases Create and run SQL commands in.
A Guide to Oracle9i1 Advanced SQL And PL/SQL Topics Chapter 9.
Introduction to Structured Query Language (SQL)
A Guide to MySQL 3. 2 Objectives Start MySQL and learn how to use the MySQL Reference Manual Create a database Change (activate) a database Create tables.
Concepts of Database Management Sixth Edition
SQL Query Extras MIS 433. Rerunning the last Query n Type the forward slash “/” to rerun the last query that was entered.
Oracle Data Definition Language (DDL)
Advance Computer Programming Java Database Connectivity (JDBC) – In order to connect a Java application to a database, you need to use a JDBC driver. –
Session 5: Working with MySQL iNET Academy Open Source Web Development.
Chapter 6: Integrity and Security Thomas Nikl 19 October, 2004 CS157B.
ASP.NET Programming with C# and SQL Server First Edition
PHP Programming with MySQL Slide 8-1 CHAPTER 8 Working with Databases and MySQL.
AL-MAAREFA COLLEGE FOR SCIENCE AND TECHNOLOGY INFO 232: DATABASE SYSTEMS CHAPTER 7 INTRODUCTION TO STRUCTURED QUERY LANGUAGE (SQL) Instructor Ms. Arwa.
Concepts of Database Management Seventh Edition
Database Programming Sections 13–Creating, revoking objects privileges.
HAP 709 – Healthcare Databases SQL Data Manipulation Language (DML) Updated Fall, 2009.
Chapter 7 Working with Databases and MySQL PHP Programming with MySQL 2 nd Edition.
Chapter 7 Working with Databases and MySQL PHP Programming with MySQL 2 nd Edition.
CS 3630 Database Design and Implementation. Your Oracle Account UserName is the same as your UWP username Followed Not case sensitive Initial.
CHAPTER:14 Simple Queries in SQL Prepared By Prepared By : VINAY ALEXANDER ( विनय अलेक्सजेंड़र ) PGT(CS),KV JHAGRAKHAND.
Introduction to SEQUEL. What is SEQUEL? Acronym for Structural English Query Language Acronym for Structural English Query Language Standard language.
SQL SQL Server : Overview SQL : Overview Types of SQL Database : Creation Tables : Creation & Manipulation Data : Creation & Manipulation Data : Retrieving.
Controlling User Access. Objectives After completing this lesson, you should be able to do the following: Create users Create roles to ease setup and.
Chapter 6 Database Administration
Concepts of Database Management Seventh Edition
SQL FUNDAMENTALS SQL ( Structured Query Language )
1 Structured Query Language (SQL). 2 Contents SQL – I SQL – II SQL – III SQL – IV.
1 Creating and Modifying Database Objects. 2 An Oracle database consists of multiple user accounts Each user account owns database objects Tables Views.
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.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting MySQL – Inserting Data.
A Guide to MySQL 3. 2 Introduction  Structured Query Language (SQL): Popular and widely used language for retrieving and manipulating database data Developed.
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
Dale Roberts 1 Department of Computer and Information Science, School of Science, IUPUI Dale Roberts, Lecturer Computer Science, IUPUI
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
SQL Fundamentals  SQL: Structured Query Language is a simple and powerful language used to create, access, and manipulate data and structure in the database.
Commercial RDBMSs Access and Oracle. Access DBMS Architchecture  Can be used as a standalone system on a single PC: -JET Engine -Microsoft Data Engine.
Prince Sultan University Dept. of Computer & Information Sciences CS 340 Introduction to Database Systems.
1 Chapter 2: Creating and Modifying Database Objects.
Personal Oracle8i Create a new user Create a new table Enter data into a new table Export & import data Start and exit SQL Plus SQL Plus Syntax.
Chapter 5 : Integrity And Security  Domain Constraints  Referential Integrity  Security  Triggers  Authorization  Authorization in SQL  Views 
©Silberschatz, Korth and Sudarshan1 Structured Query Language (SQL) Data Definition Language Domains Integrity Constraints.
Oracle 9i. Agenda Start and exit SQL Plus (General) Start and exit SQL Plus (Tah 1006) Syntax Create a new user Create a new table Enter data into a new.
Altering Tables and Constraints Database Systems Objectives Add and modify columns. Add, enable, disable, or remove constraints. Drop a table. Remove.
1 CS 430 Database Theory Winter 2005 Lecture 11: SQL DDL.
Oracle 11g: SQL Chapter 7 User Creation and Management.
Starting with Oracle SQL Plus. Today in the lab… Connect to SQL Plus – your schema. Set up two tables. Find the tables in the catalog. Insert four rows.
Basic SQL*Plus edit and execute commands SQL*Plus buffer and built-in editor holds the last SQL statement Statements are created in free-flow style and.
LM 5 Introduction to SQL MISM 4135 Instructor: Dr. Lei Li.
SQL Triggers, Functions & Stored Procedures Programming Operations.
Physical Model Lecture 11. Physical Data Model The last step is the physical design phase, In this phase data is – Store – Organized and – Access.
Concepts of Database Management, Fifth Edition Chapter 3: The Relational Model 2: SQL.
Dept. of Computer & Information Sciences
3 A Guide to MySQL.
TABLES AND INDEXES Ashima Wadhwa.
SQL and SQL*Plus Interaction
SQL in Oracle.
ORACLE SQL Developer & SQLPLUS Statements
Chapter 7 Working with Databases and MySQL
Chapter 8 Working with Databases and MySQL
Chapter 8 Advanced SQL.
Presentation transcript:

ORACLE Using ORACLE 8 SQL using ORACLE 8 PL/SQL using ORACLE 8

SQL Data Types Numeric Data Types String Data Types Data/Time Data Types

SQL Data Types (Numeric) INTEGERsigned integer 31 bits SMALLINTsigned integer 15 bits DECIMAL(p, q)signed number p digits, q decimals FLOAT(p) floating point number, p bits precision

SQL Data Types (String) CHAR(n) fixed length string, of n-8 bits VARCHAR(n) varying length string, up to n-8 bits GRAPHIC(n) fixed length string, n-16 bits VARGRAPHIC(n) varying length string n- 16 bits

SQL Data Types (Date/Time) DATE date (yyyy-mmm-dd) TIMEtime (hh:mm:ss) TIMESTAMP combination of date and time

Basic Table Level Operations Creation: Using the create command Populating tables: Entering values into the table using the insert command Modifying data: Modifying data in the tables using the update command Deleting data: Deleting data from tables using the delete command Altering tables: Using the alter command Deleting tables: Deleting tables using the drop command

Creating Tables create table ( [constraint], … …… );

Example using “create” create table CD_MASTER ( CD_NOnumber CONSTRAINT pk_cd PRIMARY KEY, CD_NAMEvarchar2(25), ARTISTvarchar2(25), TYPEvarchar2(15) );

Inserting Data insert into (first_column, second_column, … last_column) values (first_value, second_value, … );

Example using “insert” insert into CD_MASTER values (101, ‘Fields of Gold’, ‘Sting’, ‘Rock’); insert into CD_MASTER values(102, ‘Supernatural’, ‘Santana’, ‘Rock’); insert into CD_MASTER values (103, ‘Division Bell’, ‘Pink Floyd’, ‘Rock’);

Modifying data update set = where ;

Deleting Data delete from where ;

Altering table definitions alter table add | drop | modify ( );

Deleting tables drop table [cascade constraints];

Alternate way of data entry è Create tables from using the an SQL command (.SQL) file. Specify all the table definitions & constraints. è Create a “control” file (.CTL), giving specific instructions on interpreting a certain data file èList out all data in the data file

The SQL command file Specify the exact SQL commands for creating tables using the create statement, exactly the same way as on the SQL prompt Drop a table before creating it

The Control File Structure: load data infile into table fields terminated by ',' optionally enclosed by '"' (,, …, )

Example control file (save this in cdmaster.ctl) load data infile ‘cdmaster.dat’ into table CD_MASTER fields terminated by ',' optionally enclosed by '"' (CD_NO, CD_NAME, ARTIST, TYPE)

The Data File field1_val1, field2_val1, … field1_val2, field2_val2, … field1_val3, field2_val3, … field1_val4, field2_val4, … field1_val5, field2_val5, … … …...

Example data file (save this in cdmaster.dat) 101,‘Fields of Gold’,‘Sting’,‘Rock’ 102,‘Supernatural’,‘Santana’,‘Rock’ 103,‘Division Bell’,‘Pink Floyd’,‘Rock’ 104,'ABBA Gold','ABBA','Pop' 105,'Unconditional','Classy Davidson','Country'

Running the scripts telnet to zaurak.cis.ksu.edu sqlplus –creates the tables in SQL sqlldr name/password control= –populates the table specified in ctrlfile.ctl –Note: The filename should not be in quotes

Useful commands / : Executes the previous command ed: Opens edit buffer for typing in and modifying commands help: Online ORACLE help password: To change the user’s password

The Spooler Syntax: SPOOL [OFF | ] e.g. spool a.spl –saves the screen display into a file a.spl e.g. spool off – turns off the spooler

Useful ORACLE-SQL commands DESCRIBE: Shows the structure of a database table Syntax: describe ; can be shortened to desc ;

The system table “tab” tab: It’s the table of tables, i.e. stores the names of all the tables created by the user select * from tab; – lists all the tables created

The system table ALL_OBJECTS Stores details of all the tables created by all the users on the system. select OWNER from ALL_OBJECTS; –lists all the owners on the system select OBJECT_NAME from ALL_OBJECTS where owner=‘NJAGAN’ –lists all tables owned by user “NJAGAN”

The system table ALL_USERS Keeps information of all the user accounts created on the system Structure: – e.g. select * from ALL_USERS –lists all the users who hold accounts on the ORACLE server

Granting privileges GRANT –Grants a privilege to a user –Can grant privilege only if you have been granted that privilege (or if you are the administrator) grant to ;

Examples of granting roles grant create table to john; grant all on CD_MASTER to tom; grant SELECT ON CD_MASTER.CD_NAME to john; grant select, update on CD_DB to tom; grant references(CD_NO) on CD_DB to john;

Revoking roles REVOKE –Revokes a privilege from a user –Can revoke privilege only if you have been granted that privilege (or if you are the administrator) revoke from ;

Examples of revoking roles revoke DROP ANY TABLE from tom, john; revoke DELETE on CD_NAME from tom; revoke references on CD_MASTER.CD_NO from tom;

Stored Procedures a group of PL/SQL statements that you can call by name must have CREATE PROCEDURE system privilege

Syntax of stored procedures create procedure. (parameters…) as begin … end;

Example of a stored procedure CREATE PROCEDURE sam.credit (acc_no IN NUMBER, amount IN NUMBER) AS BEGIN UPDATE accounts SET balance = balance + amount WHERE account_id = acc_no; END;

Triggers Stored procedure associated with a database table Automatically fired when the specified trigger condition is satisfied

Trigger Conditional Predicates INSERTING DELETING UPDATING UPDATING (column_name)

Types of Triggers Trigger BEFORE AFTER FOR EACH ROW

Trigger Structure create trigger [before | after] [insert | update | delete] on [for each row] begin … end;

Uses of Triggers to provide sophisticated auditing and transparent event logging to automatically generate derived column values to enforce security to maintain replicate tables

Event logging trigger CREATE TRIGGER audit_trigger BEFORE INSERT OR DELETE OR UPDATE ON classified_table FOR EACH ROW BEGIN IF INSERTING THEN INSERT INTO audit_table VALUES (USER || ' is inserting' || ' new key: ' || : new.key); END IF; END;

Views logical table that contains data from other tables and views no extra storage space restrict access to predetermined sets of rows/columns updateable essentially results of a query

Syntax for creating views create view as ; Example: create view CD_LIST as select CD_NAME, CD_ARTIST from CD_MASTER;

Database Computing Thin Client / Thick Server Thick Client / Thin Server