Monday, December 30, 2013

PL/SQL Queries:

Query to get the body of a package:

select text

from   dba_source

where    NAME = 'GME_RESCHEDULE_BATCH_PVT'
;

Query to alter a session/ change the time and date format:

alter session set nls_date_format='mm/dd/yy hh24:mi:ss';

Query to insert multiple records:

INSERT ALL
  INTO LINE_DETAILS (Line_Number, Line_Name, Work_Start_time , Work_End_time, Working_Days) VALUES (1, 'Green', null,null,null)
  INTO LINE_DETAILS (Line_Number, Line_Name, Work_Start_time , Work_End_time, Working_Days) VALUES (2, 'Red', null,null,null)
  INTO LINE_DETAILS (Line_Number, Line_Name, Work_Start_time , Work_End_time, Working_Days) VALUES (3, 'Yellow', null,null,null)
  INTO LINE_DETAILS (Line_Number, Line_Name, Work_Start_time , Work_End_time, Working_Days) VALUES (4, 'Blue', null,null,null)
  INTO LINE_DETAILS (Line_Number, Line_Name, Work_Start_time , Work_End_time, Working_Days) VALUES (5, 'Voilet', null,null,null)
  --INTO LINE_DETAILS (column1, column2, column3) VALUES ('val2.1', 'val2.2', 'val2.3')
  --INTO LINE_DETAILS (column1, column2, column3) VALUES ('val3.1', 'val3.2', 'val3.3')
SELECT * FROM dual;

Query to delete the table records/ delete the table(Drop):

truncate table LINE_DETAILS;

Query to change the column name in table:

UPDATE LINE_DETAILS

   SET column = REPLACE(hr.Line_Details.Line_Name, 'Line1', 'Green');

Query to add a column in table:

ALTER TABLE LINE_DETAILS
ADD Line_Name Varchar2(100);

Query to change a value in table:

UPDATE LINE_DETAILS
SET Line_Name='Voilet'
WHERE Line_Number=5;




No comments:

Post a Comment