Thursday, October 19, 2023

How to know Postgresql server uptime ?

 

Login as privileged user to database 


Query :


SELECT pg_postmaster_start_time();



output :


demo1=> SELECT pg_postmaster_start_time();

   pg_postmaster_start_time

-------------------------------

 2023-10-19 08:46:45.432054+00

(1 row)



demo1=>

Friday, September 22, 2023

Test Endpoint failed: Application-Status: 1020912, Application-Message: Cannot connect to ODBC provider ODBC general error., Application-Detailed-Message: RetCode: SQL_ERROR SqlState: HY000 NativeError: 1130 Message: [MySQL][ODBC 8.0(w) Driver]Host '10.1.1.12' is not allowed to connect to this MySQL server

 Test Endpoint failed: Application-Status: 1020912, Application-Message: Cannot connect to ODBC provider ODBC general error., Application-Detailed-Message: RetCode: SQL_ERROR SqlState: HY000 NativeError: 1130 Message: [MySQL][ODBC 8.0(w) Driver]Host '10.1.1.12' is not allowed to connect to this MySQL server



Solution :


You have to allow database port in Source security group and test the port using telnet 


Thursday, September 21, 2023

Copy data from one table to another table using procedure with oracle Hints

 

DECLARE

 i NUMBER := 0; 

 

 CURSOR G1 IS SELECT /*+ parallel(8) */ * FROM AWAIS; 

 

 BEGIN 

  FOR c1 in G1 LOOP 

    INSERT /*+ APPEND */ INTO AWAIS_STG (EMPLOYEE_ID, FIRST_NAME, LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) VALUES (c1.EMPLOYEE_ID, c1.FIRST_NAME, c1.LAST_NAME,c1.EMAIL,c1.PHONE_NUMBER,c1.HIRE_DATE,c1.JOB_ID,c1.SALARY,c1.COMMISSION_PCT,c1.MANAGER_ID,c1.DEPARTMENT_ID) ; 

i:=i+1; 

if i> 4096

THEN 

  COMMIT; 

  DBMS_OUTPUT.PUT_LINE('Total rows: '|| 'COMMIT');

i:=0; 

    END IF; 

END LOOP;   

END;

Wednesday, September 20, 2023

How to copy data from one table to another table using PL/SQL procedure - cursor commit interval ?

 

Copy data from one table to another table using PL/SQL procedure - cursor 


DECLARE

 i NUMBER := 0; 

 

 CURSOR G1 IS SELECT * FROM AWAIS; 

 

 BEGIN 

  FOR c1 in G1 LOOP 

    INSERT INTO AWAIS_STG (EMPLOYEE_ID, FIRST_NAME, LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) VALUES (c1.EMPLOYEE_ID, c1.FIRST_NAME, c1.LAST_NAME,c1.EMAIL,c1.PHONE_NUMBER,c1.HIRE_DATE,c1.JOB_ID,c1.SALARY,c1.COMMISSION_PCT,c1.MANAGER_ID,c1.DEPARTMENT_ID) ; 

i:=i+1; 

if i> 4096

THEN 

  COMMIT; 

  DBMS_OUTPUT.PUT_LINE('Total rows: '|| 'COMMIT');

i:=0; 

    END IF; 

END LOOP;   

END;