This action might not be possible to undo. Are you sure you want to continue?
A view is a logical representation of another table or combination of tables. A view derives its data from the tables on which it is based. These tables are called base tables. Base tables might in turn be actual tables or might be views themselves. All operations performed on a view actually affect the base table of the view. You can use views in almost the same way as tables. You can query, update, insert into, and delete from views, just as you can standard tables. Views can provide a different representation (such as subsets or supersets) of the data that resides within other tables and views. Views are very powerful because they allow you to tailor the presentation of data to different types of users. Creating a view: CREATE VIEW sales_staff AS SELECT empno, ename, deptno FROM emp WHERE deptno = 10; Querying from View:select * from sales_staff; Advantages of Views:1) 2) 3) They hide the base table names and their columns. Only selected data can be shown through views. They will not occupy any space for the data storage.
How they work: Whenever a view is called, the base table will get accessed to get the data. The end user will not know whether the data has accessed from a view or a table. In reality the data will be accessed from a base table.
Sequences are database objects from which multiple users can generate unique integers. The sequence generator generates sequential numbers, which can help to generate unique primary keys automatically, and to coordinate keys across multiple rows or tables. Without sequences, sequential values can only be produced programmatically. A new primary key value can be obtained by selecting the most recently produced value and incrementing it. This method requires a lock during the transaction and causes multiple users to wait for the next value of the primary key; this waiting is known as serialization. If developers have such constructs in applications, then you should encourage the developers to replace them with access to sequences. Sequences eliminate serialization and improve the concurrency of an application. Creating a sequence:CREATE SEQUENCE emp_sequence INCREMENT BY 1 START WITH 1;
When processing a request.CURRVAL FROM dual. PL/SQL is a completely portable. high-performance transaction processing language that offers the following advantages: 2 . Creating a synonym: CREATE SYNONYM emp_syn FOR scott. updating rows. Indexes are created on one or more columns of a table. By default B-tree indexes are created.Accessing a seqeunce:SELECT Order_seq. Indexes are useful when applications frequently query a table for a range of rows (for example. After it is created. SELECT Order_seq. Indexes can be created to increase the performance of data retrieval.NEXTVAL FROM dual. stored procedure. function or a synonym. view. Synonyms can provide a level of security by masking the name and owner of an object and by providing location transparency for remote objects of a distributed database. an index is automatically maintained and used by Oracle. Also. all employees with a salary greater than 1000 dollars) or a specific row. Oracle can use some or all of the available indexes to locate the requested rows efficiently.emp. or deleting rows) are automatically incorporated into all relevant indexes with complete transparency to the users. Just as the index in this manual helps you quickly locate specific information. an Oracle index provides an access path to table data. PL/SQL (Procedural Language/SQL) It is a procedural extension to SQL. SYNONYMS A synonym is an alias for a schema object. INDEXES Indexes are database objects associated with tables. Creating an Index CREATE INDEX employees_idx1 ON emp (ename). they are convenient to use and reduce the complexity of SQL statements for database users. Changes to table data (such as adding new rows. Synonym hides the base table name. Synonym can be created for a table.
an entire block of statements can be sent to Oracle at one time. you can write portable program libraries and reuse them in different environments. you can explicitly declare a cursor to process the rows individually. which you can use to reduce the cost and time required to build complex applications. PL/SQL also has language features to further speed up SQL statements that are issued inside a loop. Figure 1-1 PL/SQL Boosts Performance Full Portability Applications written in PL/SQL can run on any operating system and platform where the Oracle database runs. PL/SQL uses both implicit and explicit cursors. Besides allowing you to create software components that are modular. With PL/SQL. maintainable. With PL/SQL. PL/SQL implicitly declares a cursor for all SQL data manipulation statements on a set of rows. including queries that return only one row. resulting in significant network and performance overhead. This can drastically reduce network traffic between the database and an application. CURSORS 3 . Oracle must process SQL statements one at a time. and reusable. As Figure 1-1 shows. For queries that return more than one row. Programs that issue many SQL statements require multiple calls to the database.• Better Performance • Full Portability • Support for Object-Oriented Programming Better Performance Without PL/SQL. Support for Object-Oriented Programming Object types are an ideal object-oriented modeling tool. A cursor is a name for a specific private SQL area in which information for processing the specific statement is kept. you can use PL/SQL blocks and subprograms to group SQL statements before sending them to the database for execution. object types allow different teams of programmers to develop software components concurrently.
FUNCTIONS • It is one of the PL/SQL Subprograms. Packages usually have two parts. Commit. exceptions. PACKAGES A package is a database object that groups logically related variables and subprograms.STORED PROCEDURES • It is one of the PL/SQL Subprograms. a single call over the network can start a large job. 3) Not possible to call using EXEC command. End if. If V_new_sal > 3000 then V_new_sal := V_new_sal + 200. which lowers memory requirements and invocation overhead. Stored procedures are cached and shared among users. It declares the types. Update emp set sal = V_new_sal where empno = p_in_empno. a specification (spec) and a body. Creating a procedure: CREATE or replace procedure emp_insert ( p_in_empno IN number ) As V_new_sal number := 0. sometimes the body is unnecessary. A function is a subprogram that computes a value. / Executing a Procedure: SQL> EXEC emp_insert (7788). Because stored procedures execute in the database server. It is almost like stored procedure except it returns a value Differences:Stored Procedure 1) Need not return a value 2) Cannot be called through SQL Statements. variables. This division of work reduces network traffic and improves response times. PL/SQL stored procedures are compiled once and stored in executable form. End. Else V_new_sal := V_new_sal – 200. The specification is the interface to the package. Function 1) Must return a value. constants. 3) Can be called using EXEC command. and subprograms that can be 4 . cursors. Begin Select sal into V_new_sal From emp where empno=p_in_empno. so procedure calls are efficient. 2) Can be called through SQL Statements.
You can think of the spec as an interface and of the body as a black box. or replace a package body without changing the package spec. Arrays Triggers Supported BEFORE triggers AFTER triggers INSTEAD OF triggers Database Event triggers AFTER triggers INSTEAD OF triggers DDL Triggers 5 . B-Tree indexes Function-based indexes Advanatges:PL/SQL statements • To enforce complex business rules that are not definable using constraints like Java methods (PK. This simplifies maintenance and enhancement. Also. The package hides the implementation of the private subprogram so that only the package (not your application) is affected if the implementation changes. • Automatically carry onThird-generation some activites on different tables whenever some DML Relational tables T-SQL Statements. three might be public and one private.NET compatible (3GL) routines Capabilities. • Better Performance When you call a packaged subprogram for the first time. Object-oriented External tables programming tables Index organized Supported from SQL Server . Not null & Check). and subprograms are public (visible and accessible) or private (hidden and inaccessible). The body defines the queries for the cursors and the code for the subprograms. Advantages of Packages:• Information Hiding With packages. by hiding implementation details from users. enhance. Unique. or trigger. Relational tables language Programming Temporary tables Temporary tables . no matter Indexes are implicitly fired byOraclewhen a triggering eventSQL Server Bitmap indexes which user is connected or which application is being used.FK. A trigger stored in the database can include SQL and PL/SQL.2005 A procedure is explicitly run by a user. TRIGGERS Triggers are similar to stored procedures. operations are done. However. the whole package is loaded into memory. procedures and triggers differ in the way that they SQL Server are invoked. application. items. Later calls to related subprograms in the package require no disk I/O.referenced from outside the package. For example. Oracle B-Tree indexes. Triggers Oracle occurs. You can debug. you protect the integrity of the package. if a package contains four subprograms. you can specify which types. Partitioned tables Tables Partitioned tables language.
This action might not be possible to undo. Are you sure you want to continue?
We've moved you to where you read on your other device.
Get the full title to continue listening from where you left off, or restart the preview.