Unit 1 - Advanced SQL

Size: px
Start display at page:

Download "Unit 1 - Advanced SQL"

Transcription

1 Unit 1 - Advanced SQL This chapter describes three important aspects of the relational database management system Transactional Control, Data Control and Locks (Concurrent Access). Transactional Control provides way to save the successful work permanently or to undo the mistakes. Data Control provides way to restrict users from performing particular operations on specific tables. Lock provides concurrent access in proper way to prevent any kind of anomaly. TCL Transaction Control Language Definition: A Transaction is a set of database operations that performs a particular task. A transaction must be completely successful or completely fail without doing anything to maintain database consistency. Example, Successfully Complete Transaction: A task, say fund transfer from one account to another account. To complete a transaction needs to update balance in two accounts source and destination. It requires two database operations: one, to debit an amount in source account and to credit that amount in destination account. Example, Fail Transaction: In a fund transfer, if a system failure occurs after debiting amount from source account, but before crediting it to destination account then database will be in inconsistent state. So, balance should be updated in both the accounts in both accounts or not in anyone. We can say that a transaction is considered as a sequence of database operations. These operations involve various data manipulation operations such as insert, update and delete. These operations are performed in two steps: 1) Changes are made in memory only. 2) Changes are permanently saved to hard disk. A transaction begins with the execution of first SQL statement after a COMMIT and can be undone using ROLLBACK command. A transaction can be closed by using COMMIT or ROLLBACK command. When a transaction is closed, all the locks acquired during that transaction are released. TCL commands are used to manage transactions, that are given below: 1) Commit 2) Rollback 3) Savepoint COMMIT: Committing a Transaction There are two ways to commit a transaction: 1) Explicitly 2) Implicitly 1) Explicit Commit: o To commit a transaction explicitly, user needs to request COMMIT command explicitly. 1

2 Unit 1 - Advanced SQL o A COMMIT command terminates the current transaction and makes all the changes permanent. o Various data manipulation operations such as insert, update and delete are not effect permanently until they are committed. COMMIT; Commit complete 2) Implicit Commit: o There are some operations which forces a COMMIT to occur automatically, even user don t specify the COMMIT command. o Some of commands are given below: 1. Quit Command: To end SQL*PLUS session disconnecting from the Oracle. 2. Exit Command: To end SQL*PLUS session disconnecting from the Oracle. 3. Data Definition Language(DDL) commands: Commands like CREATE.., ALTER.., DROP.. are immediate and makes all prior changes, made during current transaction permanent. ROLLBACK: Canceling a Transaction Completely A transaction can be cancelled using ROLLBACK command either completely or partially. A ROLLBACK command terminates the current transaction and undone any changes made during the transaction. Oracle also performs auto rollback. In situation like, Computer failure, Oracle automatically rollbacks any uncommitted work, when the database bought back next time. SAVEPOINT: Cancelling a Transaction Partially A ROLLBACK command can also used to terminate the current transaction partially. ROLLBACK TO SAVEPOINT savepoint_name; Rollback Complete. It is required to create a savepoint to cancel transaction partially. A savepoint marks and save the current point in the processing of a transaction. A savepoint can be created using command SAVEPOINT as given below: SAVEPOINT savepoint_name; Savepoint created. 2

3 Unit 1 - Advanced SQL When a ROLLBACK is used with SAVEPOINT, part of the transaction is cancelled. All the operations performed after creating a savepoint are undone. It is also possible to create more than one savepoint within a single transaction. DCL Data Control Language Security of information stored in database is one of the prime concerns for any database management system. An unauthorized access to a database must be prevented. The rights allow the user to use database contents are called privileges. Oracle provides security to database contents in two phases: o User requiring an access to database must have valid user id and password to get login in the system. o User must have privileges to access contents of the database. In a multi-user system, different user needs to access different parts of the database. The database designer determines which user needs access to which part of the database. According to this, various privileges are granted to different users. Example: In a banking system, customers need to access information about their own account only. So, they should have access to view information about their own account. But they should not allow to modify any information. Any customer must not be allowed to change balance of an account. Also, they should be prevented from accessing accounts of other customers. A user owns the database objects, such as tables, created by his/her self. If any user needs to access objects belonging to other user then the owner of the object requires to give permission for such access. Oracle provides two commands- GRANT and REVOKE. To control the access of various database objects. GRANT Granting Privileges GRANT command is used to granting privileges means to give permission to some user to access database object or a part of a database object. This command provides various types of access to database object such as tables, views and sequences. GRANT object privileges ON object name TO user name [ WITH GRANT OPTION ]; The owner of a database object can grant all privileges or specific privileges to other users. The WITH GRANT OPTION allows the grantee. User to which privilege is granted to in turn grant object privilege to other users. User can grant all or specific privileges owned by him/her. The table, given in below illustrates various object privileges. 3

4 Unit 1 - Advanced SQL Privilege ALL ALTER DELETE INDEX INSERT REFERENCES SELECT UPDATE Allows user To perform all the operation listed below. To change the table structure using ALTER command. To delete records from the table using DELETE command. To create an index on the table using CREATE INDEX command. To insert records into the table using INSERT INTO command. To reference table while creating foreign keys. To query the table using SELECT command. To modify the records in the table using UPDATE command. Example: Consider three users user1, user2 and user3 and a table - Customer is owned by user1. As a user1, grant user2 all the data manipulation permission on the table Customer, with allowing him to pass privileges to other users. GRANT ALL ON Customer TO user2 WITH GRANT OPTION; Grant Succeeded. Observe the use of WITH GRANT OPTION. If this option is not specified, user2 will have privileges, but he cannot grant these privileges to other users. Example: As a user2, grant select and insert privileges to user3. Grant SELECT, INSERT ON user1.customer TO user3; Grant Succeeded. In above example, the use of owner_name.object_name with ON clause. Example: As a user2, display all the information stored in Customer table. SELECT * from user1.customer; 4

5 Unit 1 - Advanced SQL To perform any operation on Customer table, user2 needs to suffix owner name, i.e user1, with Customer table. REVOKE Revoking Privileges Revoking privileges means to deny (decline) permission to user given previously. The owner on an object can revoke privileges granted to another user. A user of the object, who is not an owner, but has been granted privileges using WITH GRANT OPTION, can revoke the privilege from the grantee. REVOKE object privileges ON object name FROM user name; Example: As a user2, revoke the select and insert privileges from user3. Revoke SELECT, INSERT ON user1.customer FROM user3; Revoke succeeded. Here user1 is owner of the Customer table. Locks A transaction is a set of database operation that performs a particular task. A transaction may involve single SQL statement known as Single Query Transaction (SQT). A transaction may involve multiple SQL statement known as Multiple Query Transaction (MQT). For any database system, it is necessary to allow multiple users to access data simultaneously (concurrently). When multiple users are accessing data concurrently, it is difficult to ensure data integrity. Such kind of access may result in concurrent access anomaly (irregularly). The technique used to protect data when multiple users are accessing it concurrently is called Concurrency Control. Oracle uses a method called locking to implement Concurrency Control. Locking means to restrict other users from accessing data temporarily. Lock also can be defined as a mechanism used to ensure data integrity while allowing maximum concurrent access to data. There are two type of locking: o Implicit Locking o Explicit Locking 5

6 Unit 1 - Advanced SQL Implicit Locking Data in a table are locked automatically while executing SQL statements. This does not require any user interference. Such types of locks are called Implicit Locks. While applying lock on data, Oracle determines two issues: 1. Type of lock 2. Level of lock Various types and levels of locks are described below: 1) Types of Locks: o Oracle uses two different types of locks: Shared Lock and Exclusive Lock Shared Locks: o Shared locks are applied while performing read operations. o Read operation allow to view data, mostly using SELECT statement. o Multiple shared locks can be placed simultaneously on a table or other object. o As read operation does not modify table data. So multiple read operations can be performed simultaneously without causing any problem in data integrity. o This means, multiple users can simultaneously read the same data. Exclusive Locks: o Exclusive locks are applied while performing write operations. o Write operation allow to modify data using INSERT, UPDATE or DELETE statement. o Only one exclusive lock can be placed on a table or other object. o As write operation modifies table data, multiple write operations can affect the data integrity and result in inconsistent database. o This means, multiple users cannot modify the same data simultaneously. Deadlocks o A set of transaction is deadlocked, if each transaction in the set is waiting for a lock held by some other transaction in the set. o Here, each transaction is waiting to acquire some lock. But none of them will release any lock, as they all are waiting to acquire locks. o So, all the transactions will continue to wait forever. o A process with two or more threads can deadlock when the following conditions hold: Transactions that are already holding locks request new locks. The requests for new locks are made concurrently. Two or more transaction form a circular chain in which each transaction waits for a lock which is held by the next transaction in the chain. o Example: Transaction A has acquired lock on X and is waiting to acquire lock on Y. While, Transaction B has acquire lock on Y and is waiting to acquire lock on X. But none of them can execute further. 6

7 Unit 1 - Advanced SQL 2) Level of Locks: o Multiple users may need to access different parts of the same table. o For example, manager of xyz branch may need to access only those accounts belonging to xyz branch while other manager may have interest in other accounts. o So, if entire table is locked by single user then others need to wait even though they have to access other part of the table. o To solve this problem and to allow maximum possible concurrent access, locks should be placed on a part of the table or on entire table depending upon the requirement. o So, if one customer is accessing its own account, other customers can access their own accounts. o Oracle provides three different levels to place an implicit lock. o These levels are determined depending upon the WHERE clause used in SQL statement. Row Level Lock: o This lock is used when a condition given in WHERE clause evaluate a single row. Example,.WHERE Student_ID = 1; o In this case, only single row (record) is locked. Other record of the table can be accessed by other users. Page Level: o This lock is used when a condition given in WHERE clause evaluate a set of rows. Example,...WHERE B_name = CE ; o In this case, only a particular set of rows are locked. Other records of the table can be accessed by other users. Table Level: o This lock is used when a SQL statement does not contain WHERE clause. o In this case, a query accesses entire table. So entire table is locked. Due to this reason, No any other user can access other part of the table. In implicit locking, a shared lock on the table is permitted even though the exclusive lock is placed on the same table. This means, if some user is modifying the contents of the table, other user can still read those contents but they getting older data. Example: o Consider that one user has updated balance for some accounts in Account table, but has not save the changes permanently using COMMIT command. o Now, if other user reads the contents of the table, the result will be the older data without updated balance. o The reason is that change is not permanent on hard disk yet. To solve this kind of problem, an explicit lock can be used. 7

8 Unit 1 - Advanced SQL Explicit Locks User can lock data in a table on its own instead of automatic locking provided by Oracle. These types of locks are called Explicit locks. An owner of a table can place an explicit lock on the table. Some other users can also place an explicit lock if they have privilege. An explicit lock always overrides the implicit locks placed by oracle on its own. An entire table or records of the table can be explicitly locked by using one of these two commands: 1) The SELECT FOR UPDATE Statement SELECT * FROM tablename FOR UPDATE [ NOWAIT ]; o This statement is used to acquire exclusive locks for performing updates on records. o Based on WHERE clause used with SELECT statement level of lock will be applied. o If table is already locked by other user then this command simply waits until that lock is released. o But, if NOWAIT is specified and table is not free, this command will return with an error message indicates Resource is Busy. o Lock will be released on executing COMMIT or ROLLBACK. o Other clauses such as DISTINCT, ORDER BY, GROUP BY and set operation cannot be used here with SELECT statement. Example: As a user1, place an exclusive lock on accounts of XYZ branch using SELECT FOR UPDATE statement. SELECT * FROM Account WHERE B_name = XYZ FOR UPDATE; Example: As a user2, update balance to 1000 for all accounts of XYZ branch. UPDATE Account SET balance = 1000 WHERE B_name = XYZ ; o In this case, user2 has to wait until user1 releases lock by using COMMIT or ROLLBACK. 2) The LOCK TABLE Statement LOCK TABLE tablename IN lockmode MODE [ NOWAIT ]; o This statement is used to acquire lock in one of the several specified modes of a given table. o If NOWAIT is specified and table is not free, this command will return with an error message indicates Resource is Busy. o Various modes of lock are described below: MODE Specifies EXCLUSIVE SHARED ROW SHARED Allows query on a table, but prohibits any other operation. Other users can only view data of a table. Allows concurrent queries, but no update operation is allowed. Specifies row level lock. User cannot lock the whole table. Allowing concurrent 8

9 Unit 1 - Advanced SQL access for all users of the table. SHARE UPDATE Same as above. Exists for compatibility with older versions. ROW EXCLUSIVE Similar to ROW SHARE, but prohibit shared locking. So, only one user can access the table at a time. Example: As a user1, place an exclusive lock on Account table using LOCK TABLE Statement. LOCK TABLE Account IN EXCLUSIVE MODE [ NOWAIT]; Example: Update the balance for account A01 to 1000 as a user1. UPDATE Account SET balance = 1000 WHERE A_No = A01 ; Now, as a user2 display the contents of the entire table and observe the balance for A01. It will show the older balance because user1 does not committed their update operation. As a user1, COMMIT the update operation and again as user2, display Account table. Now, it will show the updated balance. Here, user2 can view data of Account table, because the lock is applied in EXCLUSIVE mode, which allows other user to view data. But no other operation is allowed. So, user2 cannot modify the content of the table Account until the lock is released. Difference Between DBMS and RDBMS DBMS There are no relationships among tables. Data stored in flat file means no relationship with other data. Normalization process will not be present. It does not support client server architecture. It does not enforce any integrity constraints or security with regards to data manipulation. It is used for simpler business applications. RDBMS The database which stores data in the tables that have relationships with other tables in the database is called RDBMS. Data stored in tabular form with relationship exist among the tables. Normalization process will not be present to check database table consistency. It supports client server architecture. It enforces integrity constraints. It is used for more complex applications. 9

10 Table is considered as one kind of database object in Oracle. Like as tables, Oracle comes with few other database objects such as views, indexes, sequences, synonyms etc. These objects are not used to stored data like as tables. They are used to enhance performance and provide extra functionalities to manage data in better and flexible way. Views are basically used to enforce security in flexible way and to make complex queries easier. Indexes are used to retrieve data in faster way from the tables. Views A view is a virtual or logical table that allows to view or manipulate the parts of the tables. A view is derived from one or more tables known as base tables. A view looks like and works similarly to normal tables. But, unlike tables, a view does not have storage space to store data. A view is created by a query, i.e. a SELECT statement which uses base tables. Data for views are extracted from these base tables based on specified query. A view is dynamic and always reflects the current data of the base tables. Only definition of view is stored in the database. When a view is referenced in SQL statement following steps will be followed: o Its definition is retrieved from database. o The base tables are opened. o A query, specified in definition is executed. o A view is created on top of the base tables. When any operation is performed on view, it is actually performed on the base table. For example, any SELECT operation on view displays data from the base table. In a similar way, INSERT, UPDATE, DELETE operations modify the contents of the base table. Types of Views View can be classified into two categories based on which type of operations they allow: 1) Read-only View: o Allows only SELECT operation, this means user can only view data. o No INSERT, UPDATE or DELETE operations are allowed. This means contents of base table cannot be modified. 2) Updateable View: o Allows SELECT as well as INSERT, UPDATE and DELETE operations. This means contents of the base tables can be displayed as well as modified. Creating a View A view can be created using syntax as given below: 10

11 CREATE [ OR REPLACE ] VIEW viewname As SELECT. [ WITH READ ONLY ]; This statement creates a view based on query specified in SELECT statement. OR REPLACE option re-creates the view if it is already existing maintaining the privileges granted to view that is given by viewname. WITH READ ONLY option creates read-only views. If this option is not provided then by default updatable views are created. The SELECT statement can include WHERE, ORDER BY, GROUP BY clauses if required. A view can be created using single base table as well as multiple base tables using joins. The following examples explain how to create views and how to use them in SQL statements. Consider tables Account and Branch as given in below figure: Account Acc_No Balance B_Name Rjt A Ahmd A Srt B_Name Rjt Ahmd Srt Branch B_Address Kalawad Road, Rajkot Elisbridge,Ahmedabad Mota Bazaar, Surat An Account and a Branch table A view using Single Base Table: Example 1 : Create a view Acc_Rjt based on Account table to have only accounts belonging to Rjt branch. CREATE VIEW Acc_Rjt AS SELECT * FROM Account WHERE B_Name = Rjt ; View created. o This view can be used like as it is a table having all accounts belonging to Rjt branch in any SQL statement. o It is required to use view name instead of table name. Example 2 : Display all the accounts from Acc_Rjt view. SELECT * FROM Acc_Rjt; Acc_No Balance B_Name A Rjt 11

12 A view using Multiple Base Tables: Example 3 : Create a view Acc_Branch based on Account and Branch table having all the information about accounts and related branches. CREATE VIEW Acc_Branch AS SELECT Acc_No, Balance, Account.B_Name Branch, B_Address FROM Account, Branch WHERE Account.B_Name = Branch.B_Name; View Created. o A B_Name column will be referred as Branch in Acc_Branch view. Example 4 : Display consistent information about accounts and its branches using Acc_Branch view. SELECT * FROM Acc_Branch; Acc_No Balance Branch B_Address A Rjt Kalawad Road, Rajkot A Ahmd Elisbridge,Ahmedabad A Srt Mota Bazaar, Surat Alter View Use the ALTER VIEW statement to explicitly recompile a view that is invalid or to modify view constraints. You can also use ALTER VIEW to define, modify, or drop view constraints. Example : To recompile the view Acc_Branch. ALTER VIEW Acc_Branch COMPILE; If Oracle Database encounters no compilation errors while recompiling Acc_Branch, then Acc_Branch becomes valid. If recompiling results in compilation errors, then the database returns an error and Acc_Branch remains invalid. We can also update view by re-create the view by CREATE / REPLACE VIEW as describe above. Restriction on View For updateable view, there are some restrictions. Any view created to be updatable either using single base table or multiple base table, must not include o DISTINCT, GROUP BY and HAVING clause. o Aggregate functions like MAX, MIN, SUM, AVG, COUNT(*) and COUNT. o Set operations like UNION, UNION ALL, INTERSECT and MINUS. o Sub-queries. Advantages of View View the data without storing the data into the object. 12

13 Restricts the view of a table. i.e. can hide some of columns in the tables. Join two or more tables and show it as one object to user. Restricts the access of a table so that nobody can insert the rows into the table. There are two major advantages of views: 1) Flexible enforcement of security 2) Simplification of complex query 1) Flexible enforcement of Security: o Using views, only limited view of table data can be provided to different users. This helps in enforcing security in flexible way. Example: To allow all branch managers to access only those accounts and customers belonging to their branch only. For that there must be separate tables for each branch. But this scenario results in data redundancy and complex database design which is difficult to manage. To solve this problem, instead of create separate tables for branch, separate view can be created on the base table and privilege can be given on these views rather than entire base table. A view Acc_Rjt is created in example-1 having information regarding all the accounts belonging to Rjt branch. The following example grants all privileges to manage of Rjt branch named Rjt_Manager on this view. Example 5 : Grant all the data manipulation permission to Rjt_Manager on the view Acc_Rjt allowing him to pass privilege to other users. Grant ALL ON Acc_Rjt TO Rjt_Manager WITH GRANT OPTION; Grant Succeeded. 2) Simplification of complex Query: o Complex queries can be simplified. Example: To retrieve name of branch and address of account A01, a simple query can be fired on the view Acc_Branch created in example - 3. Example 6 : Display branch name and address for account A01. SELECT Branch, B_Address From Acc_Branch WHERE Acc_No = A01 ; 13

14 Branch B_Address Rjt Kalawad Road, Rajkot Here, Acc_Branch is created by joining Account and Branch tables, but it is acts just like a separate table having combined information from Account and Branch tables. Disadvantages of Views Cannot use DML operations on view. When table is dropped view becomes inactive. View is an object, so it occupies space. Destroying a View The DROP VIEW command drops the specified view. The base table will not be affected if a view is destroyed. If a base table is dropped or column included in view are altered then view will not be valid further. Oracle issues an error message while using such in-valid views. DROP VIEW viewname; Example 7 : Drop the view Acc_Branch. DROP VIEW Acc_Branch; View Dropped. Indexes Search is always efficient when data to be searched is sorted in some specific order such as in ascending order. If records are not sorted then any query fired on a table to search sequentially testing values of all records one by one. The following figure describes this situation. Here a customer table is unsorted and searched for a record of customer Sophia. So we need to search sequentially all records one by one. Customer Name CID Address City Jack C01 Corporation Street Manchester Emily C02 Council Area Perth Sophia C05 Corporation Street Manchester Scott C03 Sardar Colony Anand So, to make search efficient on table, data in a table need to be kept sorted. But, this requires sorting entire table on each insert, update and delete operation. 14

15 Also sorting process consumes time, resulting in overall slower and inefficient system. Also, there may be a need to search on different columns. It may be based on customer name, ID, Address or City. So, it is not possible to sort table data for each column separately. Oracle provides an object called INDEX to solve problem mention above and to make searching efficient. An Index is an ordered list of contents of the column ( or a group of columns ) of a table. An index is similar to a table. It contains at-least two columns: 1) A column having sorted data on which an index is created. 2) A column representing RowID for each row in a table. A RowID is a unique identifier for each record inserted in a table. The following figure illustrates the searching process while using index for a table. Here, Customer table is searched for a record of customer Sophia. In below figure, for simplicity RowID is considered as a three digit number. Customer RowID Name CID Address City 001 Jack C01 Kalawad Road Rajkot 002 Emily C02 C.G. Road Ahmedabad 004 Scott C03 Kamati Baug Vadodara Index Name RowID Jack 001 Emily 002 Scott 004 Whenever a query is fired on table, involving a column on which an index is created and an index consulted first instead of a table itself. An index is searched sequentially and RowID of required record is found. This RowID will give the address of the location where that record is stored in the database and record can be accessed directly. Advantage: As content of the name column is sorted in index, searching process will be faster. Also index contains only two columns. So, updating index on each insert, update, delete operation on table will not consume much time. Disadvantages: Indexes slow down DML (i.e. inserts, updates and deletes). Indexes may make your queries slower instead of faster. A RowID A Unique Identifier of a Record A RowID is a unique identifier for each record inserted in a table. A RowID is a hexadecimal string and contains logical address of the location in a database where a particular record is stored. 15

16 Oracle assigns a unique id for each and every record inserted in a table and that is used to create indexes. Oracle provides a pseudo column, named ROWID, to retrieve RowID associated with records in a table. ROWID column can be used like any other column in SELECT statement. The format for RowID can be any of the following: 1) Extended: o This format is an 18 digit string of the form OOOOOOFFFBBBBBBRRR. o This format is used by Oracle8i and higher versions. 2) Restricted: o This format is a 15 digit string separated with dots of the form BBBBBBBB.RRRR.FFF. o This format is used by Oracle7 and earlier releases. Meaning of characters given in format strings are as below : Character OOO FFF BBB RRR Specifies. Data object number identifying the database segment. Data file number identifying a file containing data. Block number in a data file identifying block containing a record. Record number in the block. Records inserted in tables are grouped into blocks. These blocks are grouped and stored into data files. There can be many data files in system. Advantage: Once a RowID is found from the index, it indicates the data file, block and the record number. So, record can be accessed directly. Thus, the time required to locate the data on the hard disk is reduced. So, data retrieval time is improved drastically. Example 8 : Display RowID along with other columns for a Customer table. SELECT RowID, Name, CID, Address, City From Customer; RowID Name CID Address City AAAFx7AABAAAKjCAAA Jack C01 Kalawad Road Rajkot AAAFx7AABAAAKjCAAB Emily C02 C.G. Road Ahmedabad AAAFx7AABAAAKjCAAC Sophia C05 RMC Chowk Rajkot AAAFx7AABAAAKjCAAD Scott C03 Kamati Baug Vadodara 16

17 Types of Indexes There are four types of indexes: 1) Duplicate Indexes 2) Unique Indexes 3) Simple Indexes 4) Composite Indexes Difference between Duplicate and Unique indexes as given below: Duplicate Indexes o An index, that allows duplicate values for index column is called a Duplicate Index. o Duplicate indexes are not created on primary and unique key because it contains duplicate value. Unique Indexes o An index, that does not allows duplicate values for index column is called a Unique Index. o A unique index is created automatically for a table, if it contains a primary key or unique key. Simple Indexes: o An index created on a single column of a table is called a Simple Index. Composite Indexes: o An index created on more than one column is called a Composite Index. Creating an Index Creating Simple Index: CREATE [UNIQUE] INDEX indexname ON tablename (columnname); o By default indexes are created as Duplicate Indexes. o If UNIQUE option is provided while creating an index, it will be considered as a unique Index. Example 9 : Create simple index on name column of a Customer table. CREATE INDEX indcustname ON Customer (Name); Index Created. Creating Composite Index: CREATE [UNIQUE] INDEX indexname ON tablename (columnname1, columnname2 ); 17

18 o If more than one column is provided while creating an index, it will be considered as as Composite Index. Otherwise, indexes are created as Simple Indexes. o If index is created on more than two columns, other column will be considered only when the previous all columns contain duplicate data. o In above syntax, second column will be considered only when the first column contains duplicate data. In such case, sorting is performed based on data of the second column. Multiple Indexes on a Table It is possible for a table to have more than one index on different columns. A table can have any number of indexes. If a table contains more than one index, a particular index is selected based on the column specified in WHERE or ORDER BY clause. Otherwise, no any index is used for that query. Multiple indexes on a tables must be created carefully. Disadvantage: o Too many indexes may degrade the overall performance. Because, whenever a record in table is inserted, deleted or updated, indexes created on the table also need to be updated. o Sorting of contents of index is required time to perform such operation. o If there are too many indexes, this processing may take a longer time resulting in slower system. o Thus, Indexes speed up the data retrieval, but they slow down the operations such as insert, update or delete o So, indexes should be created only on the columns which are used frequently in data retrieval operations. Destroying an Index DROP INDEX indexname; o This command drops an index given by indexname. o Once an index is dropped, it can be recreated whenever required. Example 10 : Drop the index ind CustName created on Customer table. DROP INDEX indcustname; Index Dropped. Sequences To distinguish different records of a table from each other, it is required that each record must have distinct values. 18

19 The primary key constrain ensures this by not allowing duplicate or NULL values in columns defined as a primary key. Such column generally contain sequential numbers such as 1, 2, 3, or combination of sequential values with some strings, such as A01, A02,. While entering data manually in insert or update operations, it is difficult to track such type of sequence. An Oracle object, a Sequence helps to ease the process of creating unique identifiers for a record in a database. A Sequence is simply an automatic counter, which generates sequential numbers whenever required. A value generated can have maximum 38 digits. A sequence can be defined for following purpose: o To generate numbers in ascending or descending order. o To provide intervals between numbers. o To caching sequence numbers in memory to speed up their availability. Creating a Sequence CREATE SEQUENCE sequencename [ START WITH n INCREMENT BY n MINVALUE n / NOMINVALUE MAXVALUE n / NOMAXVALUE CYCLE / NOCYCLE CACHE n / NOCHACHE ORDER / NOORDER ]; A default sequence created without any options, always start with 1, is in ascending order and values are incremented by 1. To change default behavior of a sequence, various option are described in figure: Option START WITH INCREMENT BY MINVALUE NOMINVALUE MAXVALUE NOMAXVALUE Specifies Specifies the first sequence number. Default for ascending sequence the minimum value: 1 Default for descending sequence the maximum value: -1 Specifies the interval between sequence numbers. It can be any positive or negative number but not zero. Default value is 1. Specifies the sequence minimum value. Specifies a minimum value 1 for ascending sequence and for descending sequence. Specifies the sequence maximum value. Specifies a maximum value for ascending sequence and -1 for descending sequence. 19

20 CYCLE NOCYCLE CACHE NOCHACHE ORDER NOORDER Specifies to repeat cycle of generating values after reaching maximum value. Specifies that no more numbers can be generated after reaching maximum value. Specifies how many values to generate in advance and to keep in memory for faster access. Minimum values is 2 for this option. Specifies that no any values will be generated in advance. Guarantees that sequence numbers are generated in order. This is only used while using parallel servers in parallel mode. Does not Guarantee that sequence numbers are generated in order while using parallel servers in parallel mode. NEXTVAL and CURRVAL Oracle provides two pseudo column NEXTVAL and CURRVAL. Once a sequence is created, you can access its values in SQL statements with the CURRVAL pseudo column, which returns the current value of the sequence. The NEXTVAL pseudocolumn, which increments the sequence and returns the new value. These pseudo columns are used with a Sequence name as described below: squencename.currval o Returns the current value of the sequence. squencename.nextval o Increases the value of the sequence and returns the next value. Generally the values generated by the Sequence are numerical values. These values can be combined with string to get required values. Ex. A01 Example 11 : Create a Sequence which generated number from 1 to 99 in ascending order and stops after generating number 99. CREATE SEQUENCE mysequence START WITH 1 INCREMENT BY 1 MINVALUE 1 MAXVALUE 99 NOCYCLE ; Sequence Created. Example 12 : Demonstrate how to generate sequential values like A01, A02,, A99 using mysequence generated in previous example. SELECT ( A LTRIM(To_CHAR(mySequence.NEXTVAL, 00 ), )) ANO FROM DUAL; 20

21 ANO A01 We can write same kind of query for INSER or UPDATE operation. Destroying a Sequence A sequence can be destroyed as described below. DROP SEQUENCE sequencename ; Example 13 : Drop the sequence mysequence created in example 11. DROP SEQUENCE mysequence; Sequence Dropped. Synonyms A synonym is an alternative name for database object such as tables, indexes, sequences. A synonym can be used to hide the actual identity of the object being referenced. For example, if there is a need to hide name of some particular table, then a synonym can be created to refer that table, hiding the original name. Another use of the synonym is to abbreviate (Shorten) the table names, particularly tables from other users. For example, user1 can create synonym for Customer table owned by user2. Appropriate privileges must be granted to a user before the user can use the synonym. Creating a Synonym: CREATE SYNONYM synonymname FOR objectname; Example 14 : As a user2, create a Synonym for Customer table owned by user1. CREATE SYNONYM Cust FOR user1.customer; Synonym Created. Destroying a Synonym: DROP SYNONYM synonymname; 21

SQL Interview Questions

SQL Interview Questions SQL Interview Questions SQL stands for Structured Query Language. It is used as a programming language for querying Relational Database Management Systems. In this tutorial, we shall go through the basic

More information

PL/SQL Block structure

PL/SQL Block structure PL/SQL Introduction Disadvantage of SQL: 1. SQL does t have any procedural capabilities. SQL does t provide the programming technique of conditional checking, looping and branching that is vital for data

More information

Oracle Syllabus Course code-r10605 SQL

Oracle Syllabus Course code-r10605 SQL Oracle Syllabus Course code-r10605 SQL Writing Basic SQL SELECT Statements Basic SELECT Statement Selecting All Columns Selecting Specific Columns Writing SQL Statements Column Heading Defaults Arithmetic

More information

RDBMS Topic 4 Adv. SQL, MSBTE Questions and Answers ( 12 Marks)

RDBMS Topic 4 Adv. SQL, MSBTE Questions and Answers ( 12 Marks) 2017 RDBMS Topic 4 Adv. SQL, MSBTE Questions and Answers ( 12 Marks) 2016 Q. What is view? Definition of view: 2 marks) Ans : View: A view is a logical extract of a physical relation i.e. it is derived

More information

CS6312 DATABASE MANAGEMENT SYSTEMS LABORATORY L T P C

CS6312 DATABASE MANAGEMENT SYSTEMS LABORATORY L T P C CS6312 DATABASE MANAGEMENT SYSTEMS LABORATORY L T P C 0 0 3 2 LIST OF EXPERIMENTS: 1. Creation of a database and writing SQL queries to retrieve information from the database. 2. Performing Insertion,

More information

1 Writing Basic SQL SELECT Statements 2 Restricting and Sorting Data

1 Writing Basic SQL SELECT Statements 2 Restricting and Sorting Data 1 Writing Basic SQL SELECT Statements Objectives 1-2 Capabilities of SQL SELECT Statements 1-3 Basic SELECT Statement 1-4 Selecting All Columns 1-5 Selecting Specific Columns 1-6 Writing SQL Statements

More information

Database Programming with SQL

Database Programming with SQL Database Programming with SQL 18-1 Objectives In this lesson, you will learn to: Define the terms COMMIT, ROLLBACK, and SAVEPOINT as they relate to data transactions List three advantages of the COMMIT,

More information

A Unit of SequelGate Innovative Technologies Pvt. Ltd. All Training Sessions are Completely Practical & Real-time

A Unit of SequelGate Innovative Technologies Pvt. Ltd. All Training Sessions are Completely Practical & Real-time SQL Basics & PL-SQL Complete Practical & Real-time Training Sessions A Unit of SequelGate Innovative Technologies Pvt. Ltd. ISO Certified Training Institute Microsoft Certified Partner Training Highlights

More information

Table of Contents. PDF created with FinePrint pdffactory Pro trial version

Table of Contents. PDF created with FinePrint pdffactory Pro trial version Table of Contents Course Description The SQL Course covers relational database principles and Oracle concepts, writing basic SQL statements, restricting and sorting data, and using single-row functions.

More information

B.H.GARDI COLLEGE OF MASTER OF COMPUTER APPLICATION. Ch. 1 :- Introduction Database Management System - 1

B.H.GARDI COLLEGE OF MASTER OF COMPUTER APPLICATION. Ch. 1 :- Introduction Database Management System - 1 Basic Concepts :- 1. What is Data? Data is a collection of facts from which conclusion may be drawn. In computer science, data is anything in a form suitable for use with a computer. Data is often distinguished

More information

Oracle. SQL(Structured Query Language) Introduction of DBMS. Build In Function. Introduction of RDBMS. Grouping the Result of a Query

Oracle. SQL(Structured Query Language) Introduction of DBMS. Build In Function. Introduction of RDBMS. Grouping the Result of a Query Oracle SQL(Structured Query Language) Introduction of DBMS Approach to Data Management Introduction to prerequisites File and File system Disadvantages of file system Introduction to TOAD and oracle 11g/12c

More information

CHAPTER: 4 ADVANCE SQL: SQL PERFORMANCE TUNING (12 Marks)

CHAPTER: 4 ADVANCE SQL: SQL PERFORMANCE TUNING (12 Marks) (12 Marks) 4.1 VIEW View: Views are virtual relations mainly used for security purpose, and can be provided on request by a particular user. A view can contain all rows of a table or select rows from a

More information

Relational Data Structure and Concepts. Structured Query Language (Part 1) The Entity Integrity Rules. Relational Data Structure and Concepts

Relational Data Structure and Concepts. Structured Query Language (Part 1) The Entity Integrity Rules. Relational Data Structure and Concepts Relational Data Structure and Concepts Structured Query Language (Part 1) Two-dimensional tables whose attributes values are atomic. At every row-and-column position within the table, there always exists

More information

Introduction to Computer Science and Business

Introduction to Computer Science and Business Introduction to Computer Science and Business This is the second portion of the Database Design and Programming with SQL course. In this portion, students implement their database design by creating a

More information

Chapter 7. Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel

Chapter 7. Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel Chapter 7 Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel 1 In this chapter, you will learn: The basic commands

More information

Data about data is database Select correct option: True False Partially True None of the Above

Data about data is database Select correct option: True False Partially True None of the Above Within a table, each primary key value. is a minimal super key is always the first field in each table must be numeric must be unique Foreign Key is A field in a table that matches a key field in another

More information

SQL: Advanced topics. Assertions

SQL: Advanced topics. Assertions SQL: Advanced topics Prof. Weining Zhang Cs.utsa.edu Assertions Constraints defined over multiple tables. No student is allowed to take more than six courses. SQL> create assertion Course_Constraint check

More information

SQL is an English like language consisting of commands to store, retrieve, maintain & regulate access to your database.

SQL is an English like language consisting of commands to store, retrieve, maintain & regulate access to your database. SQL SQL is an English like language consisting of commands to store, retrieve, maintain & regulate access to your database. SQL*Plus SQL*Plus is an application that recognizes & executes SQL commands &

More information

Creating Other Schema Objects. Copyright 2004, Oracle. All rights reserved.

Creating Other Schema Objects. Copyright 2004, Oracle. All rights reserved. Creating Other Schema Objects Copyright 2004, Oracle. All rights reserved. Objectives After completing this lesson, you should be able to do the following: Create simple and complex views Retrieve data

More information

ITCertMaster. Safe, simple and fast. 100% Pass guarantee! IT Certification Guaranteed, The Easy Way!

ITCertMaster.   Safe, simple and fast. 100% Pass guarantee! IT Certification Guaranteed, The Easy Way! ITCertMaster Safe, simple and fast. 100% Pass guarantee! http://www.itcertmaster.com Exam : 1z0-007 Title : Introduction to Oracle9i: SQL Vendor : Oracle Version : DEMO Get Latest & Valid 1Z0-007 Exam's

More information

UNIT-IV (Relational Database Language, PL/SQL)

UNIT-IV (Relational Database Language, PL/SQL) UNIT-IV (Relational Database Language, PL/SQL) Section-A (2 Marks) Important questions 1. Define (i) Primary Key (ii) Foreign Key (iii) unique key. (i)primary key:a primary key can consist of one or more

More information

EDUVITZ TECHNOLOGIES

EDUVITZ TECHNOLOGIES EDUVITZ TECHNOLOGIES Oracle Course Overview Oracle Training Course Prerequisites Computer Fundamentals, Windows Operating System Basic knowledge of database can be much more useful Oracle Training Course

More information

JSPM s Bhivarabai Sawant Institute of Technology & Research, Wagholi, Pune Department of Information Technology

JSPM s Bhivarabai Sawant Institute of Technology & Research, Wagholi, Pune Department of Information Technology JSPM s Bhivarabai Sawant Institute of Technology & Research, Wagholi, Pune Department of Information Technology Introduction A database administrator (DBA) is a person responsible for the installation,

More information

Database Systems: Design, Implementation, and Management Tenth Edition. Chapter 7 Introduction to Structured Query Language (SQL)

Database Systems: Design, Implementation, and Management Tenth Edition. Chapter 7 Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management Tenth Edition Chapter 7 Introduction to Structured Query Language (SQL) Objectives In this chapter, students will learn: The basic commands and

More information

II B.Sc(IT) [ BATCH] IV SEMESTER CORE: RELATIONAL DATABASE MANAGEMENT SYSTEM - 412A Multiple Choice Questions.

II B.Sc(IT) [ BATCH] IV SEMESTER CORE: RELATIONAL DATABASE MANAGEMENT SYSTEM - 412A Multiple Choice Questions. Dr.G.R.Damodaran College of Science (Autonomous, affiliated to the Bharathiar University, recognized by the UGC)Re-accredited at the 'A' Grade Level by the NAAC and ISO 9001:2008 Certified CRISL rated

More information

Chapter-14 SQL COMMANDS

Chapter-14 SQL COMMANDS Chapter-14 SQL COMMANDS What is SQL? Structured Query Language and it helps to make practice on SQL commands which provides immediate results. SQL is Structured Query Language, which is a computer language

More information

Interview Questions on DBMS and SQL [Compiled by M V Kamal, Associate Professor, CSE Dept]

Interview Questions on DBMS and SQL [Compiled by M V Kamal, Associate Professor, CSE Dept] Interview Questions on DBMS and SQL [Compiled by M V Kamal, Associate Professor, CSE Dept] 1. What is DBMS? A Database Management System (DBMS) is a program that controls creation, maintenance and use

More information

Database Management System 9

Database Management System 9 Database Management System 9 School of Computer Engineering, KIIT University 9.1 Relational data model is the primary data model for commercial data- processing applications A relational database consists

More information

CSC Web Programming. Introduction to SQL

CSC Web Programming. Introduction to SQL CSC 242 - Web Programming Introduction to SQL SQL Statements Data Definition Language CREATE ALTER DROP Data Manipulation Language INSERT UPDATE DELETE Data Query Language SELECT SQL statements end with

More information

Advance SQL: SQL Performance Tuning. SQL Views

Advance SQL: SQL Performance Tuning. SQL Views Advance SQL: SQL Performance Tuning SQL Views A view is nothing more than a SQL statement that is stored in the database with an associated name. A view is actually a composition of a table in the form

More information

Course Outline and Objectives: Database Programming with SQL

Course Outline and Objectives: Database Programming with SQL Introduction to Computer Science and Business Course Outline and Objectives: Database Programming with SQL This is the second portion of the Database Design and Programming with SQL course. In this portion,

More information

normalization are being violated o Apply the rule of Third Normal Form to resolve a violation in the model

normalization are being violated o Apply the rule of Third Normal Form to resolve a violation in the model Database Design Section1 - Introduction 1-1 Introduction to the Oracle Academy o Give examples of jobs, salaries, and opportunities that are possible by participating in the Academy. o Explain how your

More information

Oracle Database 11g: SQL and PL/SQL Fundamentals

Oracle Database 11g: SQL and PL/SQL Fundamentals Oracle University Contact Us: +33 (0) 1 57 60 20 81 Oracle Database 11g: SQL and PL/SQL Fundamentals Duration: 5 Days What you will learn In this course, students learn the fundamentals of SQL and PL/SQL

More information

Oracle SQL & PL SQL Course

Oracle SQL & PL SQL Course Oracle SQL & PL SQL Course Complete Practical & Real-time Training Job Support Complete Practical Real-Time Scenarios Resume Preparation Lab Access Training Highlights Placement Support Support Certification

More information

Oracle Database 12c SQL Fundamentals

Oracle Database 12c SQL Fundamentals Course Overview This course takes a unique approach to SQL training in that it incorporates data modeling theory, relational database theory, graphical depictions of theoretical concepts and numerous examples

More information

Vendor: Oracle. Exam Code: 1Z Exam Name: Oracle Database: SQL Fundamentals I. Q&As: 292

Vendor: Oracle. Exam Code: 1Z Exam Name: Oracle Database: SQL Fundamentals I. Q&As: 292 Vendor: Oracle Exam Code: 1Z1-051 Exam Name: Oracle Database: SQL Fundamentals I Q&As: 292 QUESTION 1 Evaluate the SQL statement: TRUNCATE TABLE DEPT; Which three are true about the SQL statement? (Choose

More information

5. Single-row function

5. Single-row function 1. 2. Introduction Oracle 11g Oracle 11g Application Server Oracle database Relational and Object Relational Database Management system Oracle internet platform System Development Life cycle 3. Writing

More information

BraindumpsVCE. Best vce braindumps-exam vce pdf free download

BraindumpsVCE.   Best vce braindumps-exam vce pdf free download BraindumpsVCE http://www.braindumpsvce.com Best vce braindumps-exam vce pdf free download Exam : 1z1-061 Title : Oracle Database 12c: SQL Fundamentals Vendor : Oracle Version : DEMO Get Latest & Valid

More information

Misc. Triggers Views Roles Sequences - Synonyms. Eng. Mohammed Alokshiya. Islamic University of Gaza. Faculty of Engineering

Misc. Triggers Views Roles Sequences - Synonyms. Eng. Mohammed Alokshiya. Islamic University of Gaza. Faculty of Engineering Islamic University of Gaza Faculty of Engineering Computer Engineering Dept. Database Lab (ECOM 4113) Lab 9 Misc. Triggers Views Roles Sequences - Synonyms Eng. Mohammed Alokshiya December 7, 2014 Views

More information

M.C.A. (CBCS) Sem.-III Examination November-2013 CCA-3004 : Database Concepts and Tools. Faculty Code: 003 Subject Code:

M.C.A. (CBCS) Sem.-III Examination November-2013 CCA-3004 : Database Concepts and Tools. Faculty Code: 003 Subject Code: 003-007304 M.C.A. (CBCS) Sem.-III Examination November-2013 CCA-3004 : Database Concepts and Tools Faculty Code: 003 Subject Code: 007304 Time: 21/2 Hours] [Total Marks: 70 I. Answer the following multiple

More information

RNDr. Michal Kopecký, Ph.D. Department of Software Engineering, Faculty of Mathematics and Physics, Charles University in Prague

RNDr. Michal Kopecký, Ph.D. Department of Software Engineering, Faculty of Mathematics and Physics, Charles University in Prague course: Database Applications (NDBI026) WS2015/16 RNDr. Michal Kopecký, Ph.D. Department of Software Engineering, Faculty of Mathematics and Physics, Charles University in Prague Transactions Transactional

More information

Database Systems Laboratory 5 Grouping, DCL & TCL

Database Systems Laboratory 5 Grouping, DCL & TCL Database Systems Laboratory 5 School of Computer Engineering, KIIT University 5.1 1 2 3 4 5.2 GROUP BY clause GROUP BY clause is used for grouping data. The column appearing in SELECT statement must also

More information

RDBMS-Day3. SQL Basic DDL statements DML statements Aggregate functions

RDBMS-Day3. SQL Basic DDL statements DML statements Aggregate functions RDBMS-Day3 SQL Basic DDL statements DML statements Aggregate functions SQL SQL is used to make a request to retrieve data from a Database. The DBMS processes the SQL request, retrieves the requested data

More information

Oracle Database: SQL and PL/SQL Fundamentals NEW

Oracle Database: SQL and PL/SQL Fundamentals NEW Oracle Database: SQL and PL/SQL Fundamentals NEW Duration: 5 Days What you will learn This Oracle Database: SQL and PL/SQL Fundamentals training delivers the fundamentals of SQL and PL/SQL along with the

More information

1 Prepared By Heena Patel (Asst. Prof)

1 Prepared By Heena Patel (Asst. Prof) Topic 1 1. What is difference between Physical and logical data 3 independence? 2. Define the term RDBMS. List out codd s law. Explain any three in detail. ( times) 3. What is RDBMS? Explain any tow Codd

More information

Oracle Database: SQL and PL/SQL Fundamentals Ed 2

Oracle Database: SQL and PL/SQL Fundamentals Ed 2 Oracle University Contact Us: Local: 1800 103 4775 Intl: +91 80 67863102 Oracle Database: SQL and PL/SQL Fundamentals Ed 2 Duration: 5 Days What you will learn This Oracle Database: SQL and PL/SQL Fundamentals

More information

ORACLE VIEWS ORACLE VIEWS. Techgoeasy.com

ORACLE VIEWS ORACLE VIEWS. Techgoeasy.com ORACLE VIEWS ORACLE VIEWS Techgoeasy.com 1 Oracle VIEWS WHAT IS ORACLE VIEWS? -A view is a representation of data from one or more tables or views. -A view is a named and validated SQL query which is stored

More information

MTA Database Administrator Fundamentals Course

MTA Database Administrator Fundamentals Course MTA Database Administrator Fundamentals Course Session 1 Section A: Database Tables Tables Representing Data with Tables SQL Server Management Studio Section B: Database Relationships Flat File Databases

More information

SQL functions fit into two broad categories: Data definition language Data manipulation language

SQL functions fit into two broad categories: Data definition language Data manipulation language Database Principles: Fundamentals of Design, Implementation, and Management Tenth Edition Chapter 7 Beginning Structured Query Language (SQL) MDM NUR RAZIA BINTI MOHD SURADI 019-3932846 razia@unisel.edu.my

More information

Difficult I.Q on Databases, asked to SCTPL level 2 students 2015

Difficult I.Q on Databases, asked to SCTPL level 2 students 2015 Do you know the basic memory structures associated with any Oracle Database. (W.r.t 10g / 11g / 12c)? The basic memory structures associated with Oracle Database include: System Global Area (SGA) The SGA

More information

Oracle Database: SQL and PL/SQL Fundamentals

Oracle Database: SQL and PL/SQL Fundamentals Oracle University Contact Us: 001-855-844-3881 & 001-800-514-06-9 7 Oracle Database: SQL and PL/SQL Fundamentals Duration: 5 Days What you will learn This Oracle Database: SQL and PL/SQL Fundamentals training

More information

Solved MCQ on fundamental of DBMS. Set-1

Solved MCQ on fundamental of DBMS. Set-1 Solved MCQ on fundamental of DBMS Set-1 1) Which of the following is not a characteristic of a relational database model? A. Table B. Tree like structure C. Complex logical relationship D. Records 2) Field

More information

Relational Database Language

Relational Database Language DATA BASE MANAGEMENT SYSTEMS Unit IV Relational Database Language: Data definition in SQL, Queries in SQL, Insert, Delete and Update Statements in SQL, Views in SQL, Specifying General Constraints as Assertions,

More information

What s New in MariaDB Server 10.3

What s New in MariaDB Server 10.3 What s New in MariaDB Server 10.3 What s New in MariaDB Server 10.3 Database Compatibility Enhancements PL/SQL Compatibility for MariaDB Stored Functions including packages PL/SQL Compatibility for MariaDB

More information

SQL (Structured Query Language)

SQL (Structured Query Language) Dear Student, Based upon your enquiry we are pleased to send you the course curriculum for Oracle DBA 11g SQL (Structured Query Language) Software Installation (Environment Setup for Oracle on Window10)

More information

CREATING OTHER SCHEMA OBJECTS

CREATING OTHER SCHEMA OBJECTS CREATING OTHER SCHEMA OBJECTS http://www.tutorialspoint.com/sql_certificate/creating_other_schema_objects.htm Copyright tutorialspoint.com Apart from tables, other essential schema objects are view, sequences,indexes

More information

Introduction to Computer Science and Business

Introduction to Computer Science and Business Introduction to Computer Science and Business The Database Programming with PL/SQL course introduces students to the procedural language used to extend SQL in a programatic manner. This course outline

More information

SQL IN PL/SQL. In this chapter, you will learn about: Making Use of DML in PL/SQL Page 68 Making Use of Savepoint Page 77

SQL IN PL/SQL. In this chapter, you will learn about: Making Use of DML in PL/SQL Page 68 Making Use of Savepoint Page 77 CHAPTER 4 SQL IN PL/SQL CHAPTER OBJECTIVES In this chapter, you will learn about: Making Use of DML in PL/SQL Page 68 Making Use of Savepoint Page 77 This chapter is a collection of some fundamental elements

More information

Part VII Data Protection

Part VII Data Protection Part VII Data Protection Part VII describes how Oracle protects the data in a database and explains what the database administrator can do to provide additional protection for data. Part VII contains the

More information

1. Considering functional dependency, one in which removal from some attributes must affect dependency is called

1. Considering functional dependency, one in which removal from some attributes must affect dependency is called Q.1 Short Questions Marks 1. Considering functional dependency, one in which removal from some attributes must affect dependency is called 01 A. full functional dependency B. partial dependency C. prime

More information

Oracle Database 10g: Introduction to SQL

Oracle Database 10g: Introduction to SQL ORACLE UNIVERSITY CONTACT US: 00 9714 390 9000 Oracle Database 10g: Introduction to SQL Duration: 5 Days What you will learn This course offers students an introduction to Oracle Database 10g database

More information

Weak Levels of Consistency

Weak Levels of Consistency Weak Levels of Consistency - Some applications are willing to live with weak levels of consistency, allowing schedules that are not serialisable E.g. a read-only transaction that wants to get an approximate

More information

Chapter 2. DB2 concepts

Chapter 2. DB2 concepts 4960ch02qxd 10/6/2000 7:20 AM Page 37 DB2 concepts Chapter 2 Structured query language 38 DB2 data structures 40 Enforcing business rules 49 DB2 system structures 52 Application processes and transactions

More information

Chapter 13. Concurrency Control. In This Chapter. c Concurrency Models c Transactions c Locking c Isolation Levels c Row Versioning

Chapter 13. Concurrency Control. In This Chapter. c Concurrency Models c Transactions c Locking c Isolation Levels c Row Versioning Chapter 13 Concurrency Control In This Chapter c Concurrency Models c Transactions c Locking c Isolation Levels c Row Versioning 360 Microsoft SQL Server 2012: A Beginner s Guide As you already know, data

More information

The SQL Guide to Pervasive PSQL. Rick F. van der Lans

The SQL Guide to Pervasive PSQL. Rick F. van der Lans The SQL Guide to Pervasive PSQL Rick F. van der Lans Copyright 2009 by R20/Consultancy All rights reserved; no part of this publication may be reproduced, stored in a retrieval system, or transmitted in

More information

Deccansoft softwareservices-microsoft Silver Learing Partner. SQL Server Syllabus

Deccansoft softwareservices-microsoft Silver Learing Partner. SQL Server Syllabus SQL Server Syllabus Overview: Microsoft SQL Server is one the most popular Relational Database Management System (RDBMS) used in Microsoft universe. It can be used for data storage as well as for data

More information

A transaction is a sequence of one or more processing steps. It refers to database objects such as tables, views, joins and so forth.

A transaction is a sequence of one or more processing steps. It refers to database objects such as tables, views, joins and so forth. 1 2 A transaction is a sequence of one or more processing steps. It refers to database objects such as tables, views, joins and so forth. Here, the following properties must be fulfilled: Indivisibility

More information

Oracle Database 10g: SQL Fundamentals I

Oracle Database 10g: SQL Fundamentals I Oracle Database 10g: SQL Fundamentals I Volume I Student Guide D17108GC11 Edition 1.1 August 2004 D39766 Author Nancy Greenberg Technical Contributors and Reviewers Wayne Abbott Christian Bauwens Perry

More information

Oracle User Administration

Oracle User Administration Oracle User Administration Creating user accounts User accounts consist of two components. These are: 1. User name - The name of the account. 2. Password - The password associated with the user account.

More information

Creating and Managing Tables Schedule: Timing Topic

Creating and Managing Tables Schedule: Timing Topic 9 Creating and Managing Tables Schedule: Timing Topic 30 minutes Lecture 20 minutes Practice 50 minutes Total Objectives After completing this lesson, you should be able to do the following: Describe the

More information

Chapter # 7 Introduction to Structured Query Language (SQL) Part I

Chapter # 7 Introduction to Structured Query Language (SQL) Part I Chapter # 7 Introduction to Structured Query Language (SQL) Part I Introduction to SQL SQL functions fit into two broad categories: Data definition language Data manipulation language Basic command set

More information

Oral Questions and Answers (DBMS LAB) Questions & Answers- DBMS

Oral Questions and Answers (DBMS LAB) Questions & Answers- DBMS Questions & Answers- DBMS https://career.guru99.com/top-50-database-interview-questions/ 1) Define Database. A prearranged collection of figures known as data is called database. 2) What is DBMS? Database

More information

LECTURE11: TRANSACTION CONTROL LANGUAGE DATA CONTROL LANGUAGE

LECTURE11: TRANSACTION CONTROL LANGUAGE DATA CONTROL LANGUAGE LECTURE11: TRANSACTION CONTROL LANGUAGE DATA CONTROL LANGUAGE Ref. Chapter6 From Database Systems: A Practical Approach to Design, Implementation and Management. Thomas Connolly, Carolyn Begg. 1 IS220

More information

AO3 - Version: 2. Oracle Database 11g SQL

AO3 - Version: 2. Oracle Database 11g SQL AO3 - Version: 2 Oracle Database 11g SQL Oracle Database 11g SQL AO3 - Version: 2 3 days Course Description: This course provides the essential SQL skills that allow developers to write queries against

More information

User's Guide c-treeace SQL Explorer

User's Guide c-treeace SQL Explorer User's Guide c-treeace SQL Explorer Contents 1. c-treeace SQL Explorer... 4 1.1 Database Operations... 5 Add Existing Database... 6 Change Database... 7 Create User... 7 New Database... 8 Refresh... 8

More information

Table of Contents. Oracle SQL PL/SQL Training Courses

Table of Contents. Oracle SQL PL/SQL Training Courses Table of Contents Overview... 7 About DBA University, Inc.... 7 Eligibility... 8 Pricing... 8 Course Topics... 8 Relational database design... 8 1.1. Computer Database Concepts... 9 1.2. Relational Database

More information

Review -Chapter 4. Review -Chapter 5

Review -Chapter 4. Review -Chapter 5 Review -Chapter 4 Entity relationship (ER) model Steps for building a formal ERD Uses ER diagrams to represent conceptual database as viewed by the end user Three main components Entities Relationships

More information

Oracle Database 10g: SQL Fundamentals I

Oracle Database 10g: SQL Fundamentals I Oracle Database 10g: SQL Fundamentals I Student Guide Volume I D17108GC21 Edition 2.1 December 2006 D48183 Authors Chaitanya Koratamaddi Nancy Greenberg Technical Contributors and Reviewers Wayne Abbott

More information

UNIT 2 Set Operators

UNIT 2 Set Operators Course Title: Database Systems ( M.C.A 1 st Semester ) (Evening Batch) UNIT 2 Set Operators Set operators are used to join the results of two (or more) SELECT statements.the SET operators available in

More information

Introduction to Databases, Fall 2005 IT University of Copenhagen. Lecture 10: Transaction processing. November 14, Lecturer: Rasmus Pagh

Introduction to Databases, Fall 2005 IT University of Copenhagen. Lecture 10: Transaction processing. November 14, Lecturer: Rasmus Pagh Introduction to Databases, Fall 2005 IT University of Copenhagen Lecture 10: Transaction processing November 14, 2005 Lecturer: Rasmus Pagh Today s lecture Part I: Transaction processing Serializability

More information

TRANSACTION PROCESSING PROPERTIES OF A TRANSACTION TRANSACTION PROCESSING PROPERTIES OF A TRANSACTION 4/3/2014

TRANSACTION PROCESSING PROPERTIES OF A TRANSACTION TRANSACTION PROCESSING PROPERTIES OF A TRANSACTION 4/3/2014 TRANSACTION PROCESSING SYSTEMS IMPLEMENTATION TECHNIQUES TRANSACTION PROCESSING DATABASE RECOVERY DATABASE SECURITY CONCURRENCY CONTROL Def: A Transaction is a program unit ( deletion, creation, updating

More information

Business Analytics. SQL PL SQL [Oracle 10 g] P r i n c e S e t h i w w w. x l m a c r o. w e b s. c o m

Business Analytics. SQL PL SQL [Oracle 10 g] P r i n c e S e t h i w w w. x l m a c r o. w e b s. c o m Business Analytics Let s Learn SQL-PL SQL (Oracle 10g) SQL PL SQL [Oracle 10 g] RDBMS, DDL, DML, DCL, Clause, Join, Function, Queries, Views, Constraints, Blocks, Cursors, Exception Handling, Trapping,

More information

ADVANTAGES. Via PL/SQL, all sorts of calculations can be done quickly and efficiently without use of Oracle engine.

ADVANTAGES. Via PL/SQL, all sorts of calculations can be done quickly and efficiently without use of Oracle engine. 1 PL/SQL INTRODUCTION SQL does not have procedural capabilities. SQL does not provide the programming techniques of condition checking, looping and branching that is required for data before permanent

More information

Techno India Batanagar Computer Science and Engineering. Model Questions. Subject Name: Database Management System Subject Code: CS 601

Techno India Batanagar Computer Science and Engineering. Model Questions. Subject Name: Database Management System Subject Code: CS 601 Techno India Batanagar Computer Science and Engineering Model Questions Subject Name: Database Management System Subject Code: CS 601 Multiple Choice Type Questions 1. Data structure or the data stored

More information

Oracle Class VII More on Exception Sequence Triggers RowID & Rownum Views

Oracle Class VII More on Exception Sequence Triggers RowID & Rownum Views Oracle Class VII More on Exception Sequence Triggers RowID & Rownum Views Sequence An Oracle sequence is an Oracle database object that can be used to generate unique numbers. You can use sequences to

More information

Sql Server Syllabus. Overview

Sql Server Syllabus. Overview Sql Server Syllabus Overview This SQL Server training teaches developers all the Transact-SQL skills they need to create database objects like Tables, Views, Stored procedures & Functions and triggers

More information

1. Using Bitvise SSH Secure Shell to login to CS Systems Note that if you do not have Bitvise ssh secure shell on your PC, you can download it from

1. Using Bitvise SSH Secure Shell to login to CS Systems Note that if you do not have Bitvise ssh secure shell on your PC, you can download it from 60-539 Fall 2016 Some SQL Commands 1. Using Bitvise SSH Secure Shell to login to CS Systems Note that if you do not have Bitvise ssh secure shell on your PC, you can download it from http://www.putty.org/..

More information

Relation Databases. By- Neha Tyagi PGT CS KV 5 Jaipur II Shift Jaipur Region. Based on CBSE Curriculum Class -11. Neha Tyagi, PGT CS II Shift Jaipur

Relation Databases. By- Neha Tyagi PGT CS KV 5 Jaipur II Shift Jaipur Region. Based on CBSE Curriculum Class -11. Neha Tyagi, PGT CS II Shift Jaipur Relation Databases Based on CBSE Curriculum Class -11 By- Neha Tyagi PGT CS KV 5 Jaipur II Shift Jaipur Region Neha Tyagi, PGT CS II Shift Jaipur Introduction A Database System is basically a record keeping

More information

Lecture11: Transaction Control Language Data Control Language

Lecture11: Transaction Control Language Data Control Language IS220 : Database Fundamentals Lecture11: Transaction Control Language Data Control Language College Compu a Informati Science Informati Syste De Prepared by L. Nouf Almujally & Aisha AlArfaj 1 Transaction

More information

ASSIGNMENT NO Computer System with Open Source Operating System. 2. Mysql

ASSIGNMENT NO Computer System with Open Source Operating System. 2. Mysql ASSIGNMENT NO. 3 Title: Design at least 10 SQL queries for suitable database application using SQL DML statements: Insert, Select, Update, Delete with operators, functions, and set operator. Requirements:

More information

Integrity and Security

Integrity and Security C H A P T E R 6 Integrity and Security This chapter presents several types of integrity constraints, including domain constraints, referential integrity constraints, assertions and triggers, as well as

More information

ORACLE CERTIFIED ASSOCIATE ORACLE DATABASE 11g ADMINISTRATOR

ORACLE CERTIFIED ASSOCIATE ORACLE DATABASE 11g ADMINISTRATOR ORACLE CERTIFIED ASSOCIATE ORACLE DATABASE 11g ADMINISTRATOR The process of becoming Oracle Database certified broadens your knowledge and skills by exposing you to a wide array of important database features,

More information

Why use an RDBMS? ❽ Data maintenance ❽ Standardized access ❽ Multi-user access ❽ Data protection

Why use an RDBMS? ❽ Data maintenance ❽ Standardized access ❽ Multi-user access ❽ Data protection 1 Why use an RDBMS? ❽ Data maintenance ❽ Standardized access ❽ Multi-user access ❽ Data protection 2 RDBMSs offer Data protection ❽ Recovery ❽ Concurrency ❽ Security 3 Data protection ❽ Recovery from ❽

More information

Oracle Database 11g: SQL Fundamentals I

Oracle Database 11g: SQL Fundamentals I Oracle Database 11g: SQL Fundamentals I Volume I Student Guide D49996GC11 Edition 1.1 April 2009 D59980 Authors Puja Singh Brian Pottle Technical Contributors and Reviewers Claire Bennett Tom Best Purjanti

More information

CS6302 DBMS 2MARK & 16 MARK UNIT II SQL & QUERY ORTIMIZATION 1. Define Aggregate Functions in SQL? Aggregate function are functions that take a collection of values as input and return a single value.

More information

The Structured Query Language Get Started

The Structured Query Language Get Started The Structured Query Language Get Started Himadri Barman 0. Prerequisites: A database is an organized collection of related data that can easily be retrieved and used. By data, we mean known facts that

More information

Lecture 07. Spring 2018 Borough of Manhattan Community College

Lecture 07. Spring 2018 Borough of Manhattan Community College Lecture 07 Spring 2018 Borough of Manhattan Community College 1 SQL Identifiers SQL identifiers are used to identify objects in the database, such as table names, view names, and columns. The ISO standard

More information

Database Management Systems

Database Management Systems S.Y. B.Sc. (IT) : Sem. III Database Management Systems Time : 2½ Hrs.] Prelim Question Paper Solution [Marks : 75 Q.1 Attempt the following (any THREE) [15] Q.1 (a) Explain database system and give its

More information

ACCURATE STUDY GUIDES, HIGH PASSING RATE! Question & Answer. Dump Step. provides update free of charge in one year!

ACCURATE STUDY GUIDES, HIGH PASSING RATE! Question & Answer. Dump Step. provides update free of charge in one year! DUMP STEP Question & Answer ACCURATE STUDY GUIDES, HIGH PASSING RATE! Dump Step provides update free of charge in one year! http://www.dumpstep.com Exam : 1Z0-071 Title : Oracle Database 12c SQL Version

More information

CT13 DATABASE MANAGEMENT SYSTEMS DEC 2015

CT13 DATABASE MANAGEMENT SYSTEMS DEC 2015 Q.1 a. Explain the role of concurrency control software in DBMS with an example. Answer: Concurrency control software in DBMS ensures that several users trying to update the same data do so in a controlled

More information