Posts

Showing posts from March, 2016

Create a PrimaryKey on existing table without unique values

lets assume that there was a table ABC that was already existing in the database and you want to add an additional column with unique primary key values. sql to create table ABC :   CREATE TABLE "ABC"    (    "USERNAME" VARCHAR2(30 BYTE) NOT NULL ENABLE,     "USER_ID" NUMBER NOT NULL ENABLE,     "CREATED" DATE NOT NULL ENABLE )    TABLESPACE "USERS" ; Now we  can add an additional column ID which will be populated with all unique values for PrimaryKey. alter table abc add(ID NUMBER); We will now create a sequence and get the values from the seq and insert them into table ABC new ID column: CREATE SEQUENCE SEQ_ID START WITH 1 INCREMENT BY 1 MAXVALUE 999999 MINVALUE 1 NOCYCLE; Now insert the unique values into the database with below sql: UPDATE abc SET ID = SEQ_ID.NEXTVAL; now you can add unique constraint (or) add primary key constraint to table,so that it wont take any more duplicate value into the table. alter ...

ORA-00837: Specified value of MEMORY_TARGET greater than MEMORY_MAX_TARGET

Image
In this scenario I am trying to increase the value of parameter memory_max_target.  My initial  memory_max_target = 804 I want to increase it to 900 SQL> show parameter sga NAME     TYPE VALUE ------------------------------------ ----------- ------------------------------ lock_sga     boolean FALSE pre_page_sga     boolean FALSE sga_max_size     big integer 804M sga_target     big integer 0 SQL> show parameter max_target NAME     TYPE VALUE ------------------------------------ ----------- ------------------------------ memory_max_target     big integer 804M SQL> show parameter memory NAME     TYPE VALUE ------------------------------------ ----------- ------------------------------ hi_shared_memory_address     integer 0 memory_max_target     big integer 804M memory_target     big intege...

SQLSERVER QUERIES - SQLSERVER2015

SELECT TOP 1000 [FNAME]       ,[LNAME]       ,[ID]   FROM [TESTDB].[dbo].[USERS] FNAME    LNAME    ID Arvind    Reddy    1 Ravi    Reddy    2 Tom        Shawn    3 SELECT TOP 1000 [ORDER_ID]       ,[USER_ID]       ,[ORDER_INFO]       ,[ORDER_AMT]   FROM [TESTDB2].[dbo].[USER_ORDERS]   ORDER_ID    USER_ID    ORDER_INFO    ORDER_AMT 9001            1        BOOKS        10 9002            2        SHOES        20   SELECT A.[ORDER_ID]     ...

chr function and its values - CHR and ASCII values

chr function returns the ascii letter for that integer. We know that there are 255 ascii characters defined. SQL> select chr(65) as CHR from dual; CHR – A Below code print all 255 ascii characters Sample code to check the values : begin   for i in 1..255 loop       dbms_output.put_line( 'CHR('||i||')' ||'=='|| chr(i) );     end loop;     end;     / This output might differ actually based on the chacterset you have choosen while installing you Database. DBMS_OUTPUT :    CHR(1)== CHR(2)== CHR(3)== CHR(4)== CHR(5)== CHR(6)== CHR(7)== CHR(8)== CHR(9)==    CHR(10)== CHR(11)== CHR(12)== CHR(13)== CHR(14)== CHR(15)== CHR(16)== CHR(17)== CHR(18)== CHR(19)== CHR(20)== CHR(21)== CHR(22)== CHR(23)== CHR(24)== CHR(25)== CHR(26)== CHR(27)== CHR(28)== CHR(29)== CHR(30)== CHR(31)== CHR(32)== CHR(33)==! CHR(34)==" CHR(35)==# CHR(36)==$ CHR(37)==% CHR(38)==& CHR(39)==' CHR(40)==( CHR(41)==) CHR(42...

Step by Step installation oracle 12c database on Linux 6 (centos)

Image
Assumptions : You have a some flavor of Linux operating system installed (I have used centos 6 in this example). If you cant afford a separate machine you can use Virtual box or stemware software to visualize your desktop or laptop. Assuming that you have downloaded oracle 12 software onto linux machine. If not you can download from this link   Software-Download You have full/required privileges on you Linux host. Oracle Installation Prerequisites In order to perform the installtion of oracle 12c software on Linux box you need to perform some pre-reqs, which can be done automatically or through manual updates.Please follow below instructions. Automatic Setup If you plan to use the "oracle-rdbms-server-12cR1-preinstall" package to perform all your prerequisite setup, issue the following command. #   yum install oracle-rdbms-server-12cR1-preinstall -y It will be a good option to to do an update. # yum update ******...

ENABLE REAL TIME APPLY ON STANDBY DATABASE

*********************************************************************     REAL TIME APPLY OF ARCHIVE LOG FILES IN READ ONLY MODE: ********************************************************************* SQL> select PROTECTION_MODE,PROTECTION_LEVEL FROM V$DATABASE; PROTECTION_MODE      PROTECTION_LEVEL -------------------- -------------------- MAXIMUM PERFORMANCE  MAXIMUM PERFORMANCE SQL> archive log list; Database log mode           Archive Mode Automatic archival           Enabled Archive destination           /u01/app/oracle/oraarch/ Oldest online log sequence     250 Next log sequence to archive   0 Current log sequence           252 SQL> recover managed standby database using current logfile disconnect from session; Media reco...