Overview of SQL Statements

 All operations performed on the information in an Oracle database are run using SQL statements. A SQL statement is a computer program or instruction that consists of identifiers, parameters, variables, names, data types, and SQL reserved words.

devops certification training courses malaysia


A SQL statement must be the equivalent of a complete SQL sentence, such as:

SELECT last_name, department_id FROM employees

Oracle Database only runs complete SQL statements. A fragment such as the following generates an error indicating that more text is required:

SELECT last_name;

Oracle SQL statements are divided into the following categories:

  • Data Definition Language (DDL) Statements

  • Data Manipulation Language (DML) Statements

  • Transaction Control Statements

  • Session Control Statements

  • System Control Statement

  • Embedded SQL Statements

Data Definition Language (DDL) Statements

Data definition language (DLL) statements define, structurally change, and drop schema objects.

ccna certification training courses malaysia


DDL enables you to alter attributes of an object without altering the applications that access the object. For example, you can add a column to a table accessed by a human resources application without rewriting the application. You can also use DDL to alter the structure of objects while database users are performing work in the database.

More specifically, DDL statements enable you to:

  • Create, alter, and drop schema objects and other database structures, including the database itself and database users. Most DDL statements start with the keywords CREATEALTER, or DROP.

  • Delete all the data in schema objects without removing the structure of these objects (TRUNCATE).

  • Grant and revoke privileges and roles (GRANTREVOKE).

  • Turn auditing options on and off (AUDITNOAUDIT).

  • Add a comment to the data dictionary (COMMENT).

Example 7-1 DDL Statements

The following example uses DDL statements to create the plants table and then uses DML to insert two rows in the table. The example then uses DDL to alter the table structure, grant and revoke read privileges on this table to a user, and then drop the table.

CREATE TABLE plants ( plant_id NUMBER PRIMARY KEY, common_name VARCHAR2(15) ); INSERT INTO plants VALUES (1, 'African Violet'); # DML statement INSERT INTO plants VALUES (2, 'Amaryllis'); # DML statement ALTER TABLE plants ADD ( latin_name VARCHAR2(40) ); GRANT READ ON plants TO scott; REVOKE READ ON plants FROM scott; DROP TABLE plants;

An implicit COMMIT occurs immediately before the database executes a DDL statement and a COMMIT or ROLLBACK occurs immediately afterward. In the preceding example, two INSERT statements are followed by an ALTER TABLE statement, so the database commits the two INSERT statements. If the ALTER TABLE statement succeeds, then the database commits this statement; otherwise, the database rolls back this statement. In either case, the two INSERT statements have already been committed.

careers

Comments

Popular posts from this blog

MICROSOFT SYSTEM CENTER TROUBLESHOOTING AND MAINTENANCE SERVICES COMPANY MALAYSIA

LEADING AND BEST IOS APP DEVELOPMENT COMPANY MALAYSIA