Showing posts with label SQLPLUS COMMAND LINE some set commands. Show all posts
Showing posts with label SQLPLUS COMMAND LINE some set commands. Show all posts

Wednesday, September 6, 2023

SQLPLUS COMMAND LINE some set commands

 set sqlprompt "_user '@' _connect_identifier > "

[oracle@pm admin]$ cat $ORACLE_HOME/sqlplus/admin/glogin.sql
--
-- Copyright (c) 1988, 2005, Oracle.  All Rights Reserved.
--
-- NAME
--   glogin.sql
--
-- DESCRIPTION
--   SQL*Plus global login "site profile" file
--
--   Add any SQL*Plus commands here that are to be executed when a
--   user starts SQL*Plus, or uses the SQL*Plus CONNECT command.
--
-- USAGE
--   This script is automatically run
set lines 400;
set timing on;
set time on;
-- added by kayyum
set sqlprompt "_user '@' _connect_identifier > "
[oracle@pm admin]$
[oracle@pm admin]$
[oracle@pm admin]$ sq
SQL*Plus: Release 21.0.0.0.0 - Production on Wed Sep 6 18:41:04 2023
Version 21.3.0.0.0
Copyright (c) 1982, 2021, Oracle.  All rights reserved.

Connected to:
Oracle Database 21c Enterprise Edition Release 21.0.0.0.0 - Production
Version 21.3.0.0.0
18:41:04 SYS @ sakri >




SET AUTOTRACE ON;
SELECT * FROM employees;

SET SERVEROUTPUT ON;
BEGIN
  DBMS_OUTPUT.PUT_LINE('Hello, World!');
END;
/

SET LINESIZE 100;
SELECT employee_id, first_name, last_name FROM employees;

SET PAGESIZE 25;
SELECT * FROM products;

SET FEEDBACK OFF;
SELECT * FROM customers;

SET VERIFY OFF;
SELECT '&variable_name' FROM dual;

SET HEADING OFF;
SELECT department_name FROM departments;

SET NULL "N/A";
SELECT phone_number FROM employees WHERE employee_id = 9999;

SET SQLFORMAT CSV;
SELECT * FROM products;

SET TIMING ON;
SELECT * FROM orders;

SET TRANSACTION ISOLATION LEVEL READ COMMITTED;
-- Your SQL statements here
COMMIT;


SET ECHO ON;
SELECT * FROM employees;


SET TERMOUT OFF;
SELECT * FROM customers;

SQL> SET TIMING ON;
elapsed time 00:01:00 



to see time also 
SQL> set time on;
11:00:00 SQL> --- this way we can see---

to set col size :-
col column_name for a<size>;
example: 
SQL> col student_id for a20;


to clear col size:-
clear column;
SQL> clear column;

+++++++++++++++++++++ Auto format SQLPLUS CONSOLE COLUMNS +++++++++
-- Generate COLUMN commands for all columns in a table
SELECT 'COLUMN ' || column_name || ' FORMAT ' ||
  CASE
    WHEN data_type = 'NUMBER' THEN '999999'
    WHEN data_type = 'DATE' THEN 'DATE ''YYYY-MM-DD'''
    ELSE 'A' || data_length
  END || ';'
FROM user_tab_columns
WHERE table_name = upper('&YOUR_TABLE_NAME');




Enable OpenSSH on Windows 11

Step 1: Install OpenSSH Server You can do this via PowerShell (run as Administrator ): Check if it's already available: Get-WindowsCapab...