Thursday, March 13, 2025

SQL styling and formatting !!!!!

-- Increase the size for long DDL outputs
SET LONG 10000;           -- Allows displaying long DDL statements
SET LONGCHUNKSIZE 1000;   -- Controls how LONG data is fetched and displayed

-- Formatting options
SET LINESIZE 200;         -- Adjusts output width for better readability
SET PAGESIZE 100;         -- Controls the number of lines per page (0 removes headers)
SET TRIMOUT ON;           -- Removes trailing spaces from output
SET TRIMSPOOL ON;         -- Removes trailing spaces when spooling output
SET WRAP OFF;             -- Prevents line wrapping in output

-- Improve output structure
SET COLSEP '|';           -- Adds a column separator for better visibility
SET UNDERLINE '-';        -- Adds an underline separator under column headers

-- Display settings
SET SERVEROUTPUT ON;      -- Enables DBMS_OUTPUT messages
SET VERIFY OFF;           -- Suppresses display of substitution variable values
SET FEEDBACK OFF;         -- Removes row count messages from the output
SET HEADING ON;           -- Ensures column headers are displayed
SET ECHO OFF;             -- Hides command execution in the output

-- If using spooling (saving output to a file)
SPOOL my_output.txt;

-- Your SQL queries here...

SPOOL OFF;

--For DDL Queries:
SET LONG 10000;
SET PAGESIZE 0;
SET LINESIZE 200;
SET TRIMOUT ON;
SET WRAP OFF;

--For Tabular query result
SET PAGESIZE 100;
SET LINESIZE 200;
SET COLSEP '|';
SET UNDERLINE = '-';
------------------------------------------
/* For exporting result to a file */
SET LONG 10000;
SET PAGESIZE 0;
SET LINESIZE 200;
SET TRIMOUT ON;
SET WRAP OFF;
SPOOL my_output.txt;

-- Your queries here...

SPOOL OFF;
--------------------------------------------



No comments:

Post a Comment

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...