Skip to main content

Posts

Showing posts with the label Oracle SQL

How to increse font size in Oracle SQL Developer

In Oracle SQL Developer go to Tools and select Preferences. In New window go to Code Editor and expand, select Fonts. Change the font side to desired.

How to import a CSV file into SQL Developer

Title: How to import a CSV file into SQL Developer? Loading Data into a Table Procedure: After create a connection to the database in SQL Developer. 1. Right click on tables folder and Choose Import data. 2 .Select xls. 3. Follow the wizard     - Provide table name     - Select columns     - Define datatype per column and provide the length     - Finish.

Oracle SQL concatenate multiple columns and add text

You have two options for concatenating strings and column values in Oracle: CONCAT Using || CONCAT example: select CONCAT(ROW_ID,'text') from s_contact; Using || example: select ROW_ID || 'text' from s_contact; Source: StackOverflow

SQL Developer INSERT INTO SELECT Statement

With INSERT ... SELECT , you can quickly insert many rows into a table from the result of a SELECT statement, which can select from one or many tables. For example: INSERT INTO tbl_temp2 (fld_id)   SELECT tbl_temp1.fld_order_id   FROM tbl_temp1 WHERE tbl_temp1.fld_order_id > 100;   Source: Oracle Docs   You can also insert record and set column values from multiple selects insert into S_CON_EDU (CON_ID,SCHOOL_ID,CLASS_GRADE,CREATED_BY,LAST_UPD_BY,DATE_DT,ROW_ID) ( select ( select con.row_id from s_contact con where con.IDN = '123654789'), ( select sch.row_id from S_ORG_EXT sch where sch.IDN like ( select '%'||SUBSTR('1082AB', 1, 4)||'%' from dual)), ( select lov.name from S_LST_OF_VAL lov where lov.type = 'EDU_LEVEL' and lov.active_flg = 'Y' and lov.val = 'Grade Six' ), '0-1', '0-1', SYSDATE, '1-EDU101' from dual)

How to get Host Address and Servcie Name from Oracle database

 The IP address of the database server:  select UTL_INADDR.get_host_address from dual   Get Service Name select * from global_name;  

How to get Service Name through Oracle Oracle Developer

To see what services are available in the database use following queries: select name from V$SERVICES ; select name from V$ACTIVE_SERVICES ; The V$ views are mainly dynamic views of system metrics. They are used for performance tuning, session monitoring, etc. So access is limited to DBA users by default The easiest way of finding the database name is: select * from global_name ; This view is granted to PUBLIC, so anybody can query it.

How to create SQL Views in SQL Developer from UI

 About DB Views: Views are customized presentations of data in one or more tables or other views. You can think of them as stored queries. Views do not actually contain data, but instead derive their data from the tables upon which they are based. These tables are referred to as the base tables of the view. Similar to tables, views can be queried, updated, inserted into, and deleted from, with some restrictions. All operations performed on a view actually affect the base tables of the view. Views can provide an additional level of security by restricting access to a predetermined set of rows and columns of a table. They can also hide data complexity and store complex queries. Create Views: Open SQL Developer and connect the connection (DEV, UAT, Prod), Write the desired query. Now expand the db and find the Views and right click and select the "New View" A new window will appear. Paste the query your have prepared before and provide the appropriate new and click on OK button....

How to get age from birth date in Oracle SQL

 ROUND(months_between(TRUNC( sysdate ),to_date( CON.BIRTH_DT ))/12, 2)