Skip to Main Content

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, Martijn.

Asked: July 11, 2007 - 10:16 am UTC

Last updated: August 04, 2017 - 6:19 am UTC

Version: 10.2.0.1.0

Viewed 10K+ times! This question is

You Asked

Hi Tom,

I'm pretty sure that recently I stumbled upon an article on some Oracle blog, demonstrating how to change the color of fonts in SQL*plus. (No HTML etc., just the (server)output in SQL*Plus)

Unfortunatly I didn't bookmark it, can't find the blog anymore, but at this moment it would come in quite handy to make use this feature.

Hence my question: how can one change the color of fonts in SQL*Plus?
Thanks again.

Regards,

Martijn

and Connor said...

not sure about the color (that would be a terminal thing probably?)

but font and size:
http://docs.oracle.com/cd/B19306_01/server.102/b14357/ch1.htm

Addenda 2017:
=============
Thanks to Henning for this additional info

On Windows 10, the "DOS" box now supports ANSI colors out-of-the-box.

For example, it is possible to generate coloured text output from SQL.

http://blog.tanelpoder.com/files/scripts/demos/xterm-color.sql

Rating

  (13 ratings)

Is this answer out of date? If it is, please let us know via a Comment

Comments

Changing font color in SQL*Plus (Windows Instant Client 10g)

Ken Banyas, July 12, 2007 - 12:47 pm UTC

I use SQL*Plus (from Instant Client 10g) on Windows XP.

Right-click on its title bar, then select Properties. You can change font type (not many types), size, and color.
Works fine for me.

Ken

Addendum to SQL*Plus font color change.

Ken Banyas, July 12, 2007 - 12:52 pm UTC

I also use the PuTTY terminal software to SSH from my Windows desktop to the servers. PuTTY also permits you to change pretty much everything on your term screen.

Ken

set

A reader, July 12, 2007 - 2:42 pm UTC

i read some days ago on an Oracle Blog of one of the Oracle ACEs something about
SET TRANSACTION READ ONLY
would use client time

cmp.
http://tinyurl.com/37snja

probably there is also an (undocumented)
SET TRANSACTION COLORFONT lighseagreen
and similar ?

Thanks, and one more thing

MHO, July 12, 2007 - 4:29 pm UTC

I wasn't complete, pardonnez-moi for that:

It should be possible to change the font color (more or less) conditionally, from a SQL statement, according to what I can recall from that blog...

I.e.: print negative numbers you retrieve from a *SQL*Plus* query out in red ;-), in *SQL*Plus*.

Hope I can find it back, and if I do, I'll post that method here too (unless someone else is faster/has better recall skills than me).
Ironically enough, I got on that blog through Tom's meta-blog-list, after that, it's an infinite number of ORA-blogs, they're waaay to addictive ;)

Thanks for your appreciated input, Tom and everybody!

Regards,
Martijn





Color in sqlplus

Yas, July 13, 2007 - 3:34 am UTC

Giovanni, July 13, 2007 - 5:36 am UTC

This method does not work in Windows Env. - unfortunately.

:(

Thanks!

Martijn Hoekstra, July 13, 2007 - 5:43 am UTC

Thanks Yas!

THAT was the exact link I was looking for!

(but I should have used "colour" instead of "color"..)

Regards,
Martijn

Colors in Windows Dos window

Kamal Kishore, August 13, 2007 - 3:17 pm UTC

You probably do not have the ansi.sys driver loaded on your windows system. The color escapes work only when this driver is loaded.

http://www.vfrazee.com/ms-dos/6.22/help/ansi.sys.htm

Shan's, January 01, 2016 - 1:50 pm UTC

Guys, sorry i'm new to this and now i can't find that link.. could anyone tell me in detail about this..
Connor McDonald
January 02, 2016 - 12:24 am UTC

If you are running in Windows (ie, in a command prompt) then you right click on the title bar, choose Properties, and adjust the colors.

If you are on Unix, you do so by controlling the color settings of the terminal sqlplus is running in.

In other words, sqlplus doesnt explicitly have its own color settings.

You can control it via sqlplus in a roundabout way ( by sending the terminal control codes). See here http://blog.tanelpoder.com/2012/09/19/sqlplus-is-my-second-home-part-6-colorizing-sqlplus-and-terminal-output/

Or take a look at sqlcl, scroll to the bottom of the link http://www.oracle.com/technetwork/developer-tools/sql-developer/downloads/index.html

SQLCI - Latest build

Rajeshwaran Jeyabal, January 02, 2016 - 2:48 pm UTC

SQLCI latest build from that link doesn't work properly in Windows environment.

Confirmed by Jeff, about that in this below link "comments" section

http://www.thatjeffsmith.com/archive/2015/12/sqlcl-optimizing-your-history-lists/

SQLCI - 4.2 latest download

Rajeshwaran, April 19, 2017 - 7:45 am UTC

Could you help me why either login.sql/glogin.sql doesnot applied here even after SQL_PATH and SQLPATH environment variable set in Windows 7 (64-bit) ?

C:\Users\admin>echo %SQL_PATH%
c:\users\admin

C:\Users\admin>echo %SQLPATH%
c:\users\admin

C:\Users\admin>sql /nolog

SQLcl: Release 4.2.0 Production on Wed Apr 19 13:08:52 2017

Copyright (c) 1982, 2017, Oracle.  All rights reserved.


idle> conn demo/demo@ora12c
Connected.
login.sql found in the CWD. DB access is restricted for login.sql.
Adjust the SQL_PATH to include the path to enable full functionality.


idle> exit

Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

C:\Users\admin>dir *login*.*
 Volume in drive C is OS
 Volume Serial Number is D4D1-2052

 Directory of C:\Users\admin

01/30/2017  03:02 PM             2,724 glogin.sql
01/30/2017  03:02 PM             2,724 login.sql
               2 File(s)          5,448 bytes
               0 Dir(s)  125,805,731,840 bytes free

C:\Users\admin>

Connor McDonald
April 19, 2017 - 9:17 am UTC

Reading in login.sql from the current directory is a security risk, so its been cleaned up in sqlcl and in sqlplus. But I think they havent catered for the fact that you might be *in* the sqlpath directory, eg

C:\oracle\sqlcl\bin>sql mcdonac/xxxxxxx

SQLcl: Release 4.2.0 Production on Wed Apr 19 17:14:56 2017

Copyright (c) 1982, 2017, Oracle.  All rights reserved.

Last Successful login time: Wed Apr 19 2017 17:14:57 +08:00

Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production



mcdonac@db122 SQL> exit   <---- login.sql has been run

Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

C:\oracle\sqlcl\bin>cd \oracle\sql

C:\oracle\sql>C:\oracle\sqlcl\bin\sql mcdonac/xxxxxxxxxxx

SQLcl: Release 4.2.0 Production on Wed Apr 19 17:15:24 2017

Copyright (c) 1982, 2017, Oracle.  All rights reserved.

Last Successful login time: Wed Apr 19 2017 17:15:25 +08:00

Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

login.sql found in the CWD. DB access is restricted for login.sql.
Adjust the SQLPATH to include the path to enable full functionality.


SQL>


I'll let the sqlcl guys know.

set env variable to different directory

Rajeshwaran, April 19, 2017 - 1:28 pm UTC

Thanks, set the environment variable to a different directory (other than CWD) and it went fine.

C:\Users\admin>echo %sqlpath%
D:\app

C:\Users\admin>echo %sql_path%
D:\app

C:\Users\admin>sql /nolog

SQLcl: Release 4.2.0 Production on Wed Apr 19 18:55:48 2017

Copyright (c) 1982, 2017, Oracle.  All rights reserved.

idle> conn demo/demo@ora12c
Connected.

demo@ORA12C> exit

Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

C:\Users\admin>dir d:\app\*login*.*
 Volume in drive D is DATA
 Volume Serial Number is 50D3-A8AC

 Directory of d:\app

01/30/2017  03:02 PM             2,724 glogin.sql
01/30/2017  03:02 PM             2,724 login.sql
               2 File(s)          5,448 bytes
               0 Dir(s)  254,122,549,248 bytes free

C:\Users\admin>

ANSI colors now work in Windows 10

Henning, April 21, 2017 - 3:50 pm UTC

It should be noted that on Windows 10, the "DOS" box now supports ANSI colors out-of-the-box.

So the original answer is out of date.

For example, it is possible to generate coloured text output from SQL.

http://blog.tanelpoder.com/files/scripts/demos/xterm-color.sql

I wrote a package procedure that uses DBMS_OUTPUT with ANSI escapes to display log messages from a table in different colours depending on the message severity.

Or you can have the SQLPROMPT in a different color (here: green) like this:

rem The next line should contain an Escape symbol (CHR(27)
rem Another option would be to use COLUMN ESC NEW_VALUE ESC and select CHR(27) as ESC from dual
define ESC = ''

set sqlprompt "&ESC[92m&_user@&_connect_identifier>&ESC[37;40m "


Of course this requires sqplus.exe - it will not work with the out-dated sqlplusw.exe.
Connor McDonald
April 22, 2017 - 1:38 am UTC

Thanks for the input.