Search notes:

SQLcl: ALIAS

SQL> alias obj_count = select count(*) obj_cnt from dba_objects where lower(owner) = :owner;
SQL> obj_count
Error: Alias with binds: not enough binds supplied at run time.
SQL> obj_count user

   OBJ_CNT
__________
         0

SQL> obj_count rene

   OBJ_CNT
__________
         7

SQL> obj_count system

   OBJ_CNT
__________
       481

Persisting aliases

Alias definitions are persisted in ~/.sqlcl/aliases.xml (In Windows under %APPDATA%\sqlcl\aliases.xml).

Storing and loading aliases

Note, the shell shortcut ~ for the home directory is not understood by the alias save|load command.
SQL> alias save ~/project/sqlcl/aliases
2024-01-20 12:33:48.899 SEVERE oracle.dbtools.raptor.newscriptrunner.commands.alias.Aliases save No such file or directory
ALIAS-007 - Aliases saved to ~/project/sqlcl/aliases.xml

SQL> host mkdir -p ~/project/sqlcl

SQL> alias save ~/project/sqlcl/aliases
024-01-20 12:34:35.718 SEVERE oracle.dbtools.raptor.newscriptrunner.commands.alias.Aliases save No such file or directory
ALIAS-007 - Aliases saved to ~/project/sqlcl/aliases.xml

SQL> alias save /home/rene/project/aliases
ALIAS-007 - Aliases saved to /home/rene/project/aliases.xml
SQL> alias load /home/rene/project/aliases
Aliases loaded

Multi-line aliases

SQL> alias multiline
ALIAS-001: Alias command not found

SQL> alias multiline=
  2  select
  3  *
  4  from
  5* dual;
SQL> multiline

DUMMY
________
X

Executing JS scripts with an alias

SQL> alias whoAmI=
  2  script
  3  print('Going to select USER from DUAL:')
  4  print('You are: ' + util.executeReturnOneCol('select user from dual'))
  5* /
SQL> whoAmI
Going to select USER from DUAL:
You are: RENE

See also

Is echo an undocumented alias?
SQLcl Commands

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1758199935, '216.73.216.150', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/databases/Oracle/SQLcl/commands/alias(113): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78