Posts

Showing posts from March, 2020

Types of SQL Commands

Type of SQL statements are divided into five different categories:   Data definition language (DDL) Data manipulation language (DML),  Data Control Language (DCL),  Transaction Control Statement (TCS),  Session Control Statements (SCS). DDL:(Create,Alter,Drop,Truncate,Rename) Statement Description CREATE Create new database/table. ALTER Modifies the structure of database/table. DROP Deletes a database/table. TRUNCATE Remove all table records including allocated table spaces. RENAME Rename the database/table. DML:(Insert,Update,Delete,Merge,Lock Table,Call Explain Plan) Statement Description SELECT Retrieve data from the table. INSERT Insert data into a table. UPDATE Updates existing data with new data within a table. DELETE Deletes the records rows from the table. MERGE MERGE (also called UPSERT) statements to INSERT new records or UPDATE existing records depending on condition matches or not. LOCK TABLE LOCK TABLE statement to lock one or more table

Oracle/PLSQL Sequence

Description: Sequence is a database object from which multiple users may generate unique integers. You can use sequences to automatically generate Primary Key Values. Prerequisites : To create a sequence in your own schema,you must have CREATE SEQUENCE system privilege. To create a sequence in another user's schema,you must have CREATE ANY SEQUENCE system privilege. Syntax: CREATE SEQUENCE sequence_name MINVALUE value MAXVALUE value START WITH value INCREMENT BY value CACHE value; Example: The following statement creates the sequence  CREATE SEQUENCE seq_empid MINVALUE 1 MAXVALUE 999999999999999999999999999 START WITH 1 INCREMENT BY 1 CACHE 20; The first sequence number that it would use is 1 and each subsequent number would increment by 1(i.e..2,3,4,..).It will values for performance. If you omit the MAXVALUE when creating the Sequence,it will automatically default to :     MAXVALUE 9999999999999999999999999