How to Create a Sequence in Oracle
Here is the syntax to create a sequence. This can be used to create primary keys or to generate a number sequence. The below sequence will start with 1 and increment by 1. There is no MAXVALUE defined so the sequence’s max value will default to 999999999999999999999999999. The CACHE is set to 50 so it [...]
How to Create a Function in Oracle with Examples
The following function will add a new column called SOME_NEW_COLUMN with a NUMBER datatype to all tables in the current schema. This function does not take any parameters. CREATE OR REPLACE FUNCTION ADD_COLUMN_FUNCTION RETURN INTEGER IS temp_String varchar2(200); temp_Table_Name varchar2(30); CURSOR cursor_User_Tables IS SELECT TABLE_NAME FROM USER_TABLES; BEGIN FOR rec IN cursor_User_Tables LOOP temp_Table_Name := [...]
How to Create a Stored Procedure in Oracle with Examples
The following stored procedure will add a new column called SOME_NEW_COLUMN with a NUMBER datatype to all tables in the current schema. This stored procedure does not take any parameters. CREATE OR REPLACE PROCEDURE ADD_COLUMN_STORED_PROCEDURE IS temp_String varchar2(200); temp_Table_Name varchar2(30); CURSOR cursor_User_Tables IS SELECT TABLE_NAME FROM USER_TABLES; BEGIN FOR rec IN cursor_User_Tables LOOP temp_Table_Name := [...]