Tuesday, May 7, 2013

SQL and SQLPLUS
SQL ( (Structured Query Language) is a special-purpose programming language designed for managing data held in a relational database management system (RDBMS).
Originally based upon relational algebra and tuple relational calculus, SQL consists of a data definition language and a data manipulation language. The scope of SQL includes data insert, query, update and delete, schema creation and modification, and data access control. Although SQL is often described as, and to a great extent is, a declarative language (4GL), it also includes procedural elements.
“S-Q-L” is the correct way to pronounce SQL according to the
American National Standards Institute. However, the single word
“sequel” is frequently used instead.
SQL is based on the groundbreaking work of Dr. E.F. Codd, with the first implementation of SQL being developed by IBM in the mid-1970s. IBM was conducting a research project known as System R, and SQL was born from that project. Later, in 1979, a company then known as Relational Software Inc. (known today as Oracle Corporation) released the first commercial version of SQL. SQL is now fully standardized and recognized by the American National Standards Institute. SQL uses a simple syntax that is easy to learn and use. You’ll see some simple examples of its use in this chapter. There are five types of SQL statements, outlined in the following list:-
Query statements retrieve rows stored in database tables. You write a query using the SQL 
SELECT statement.
Data Manipulation Language (DML) statements modify the contents of tables. There are three DML statements:
  • INSERT adds rows to a table.
  • UPDATE changes rows.
  • DELETE removes rows.
Data Definition Language (DDL) statements define the data structures, such as tables, that make up a database. There are five basic types of DDL statements:
  • CREATE creates a database structure. For example, CREATE TABLE is used to create
  • a table; another example is CREATE USER, which is used to create a database user.
  • ALTER modifies a database structure. For example, ALTER TABLE is used to modify
  • a table.
  • DROP removes a database structure. For example, DROP TABLE is used to remove a
  • table.
  • RENAME changes the name of a table.
  • TRUNCATE deletes all the rows from a table.
Transaction Control (TC) statements either permanently record any changes made to rows, or undo those changes. There are three TC statements:
  • COMMIT permanently records changes made to rows.
  • ROLLBACK undoes changes made to rows.
  • SAVEPOINT sets a “save point” to which you can roll back changes.
Data Control Language (DCL) statements change the permissions on database structures.There are two DCL statements:
  • GRANT gives another user access to your database structures.
  • REVOKE prevents another user from accessing your database structures.
SQLPLUS:-
Oracle has a tool called SQL*Plus that allows us to enter SQL statements using the keyboard or to run a script containing SQL statements. SQL*Plus enables you to conduct a “conversation” with the database; you enter SQL statements and view the results returned by the database.The Oracle Database 11g version of SQL*Plus is slightly nicer than the Windows-only version. In the 11g version, you can scroll through
previous commands you’ve run by pressing the UP and DOWN ARROW keys on the keyboard.

No comments:

Post a Comment