Zum Hauptinhalt wechseln

SQLcl - The alias command

Was kann man in SQLcl mit Aliassen machen? 

Alias is a command which allows you to save a sql, plsql or sqlplus script and assign it a shortcut command. The alias command is persistent. This means when you start a new SQLcl session, it will load all your previously declared aliases.

Befehlsübersicht
sqlcl> help alias

Alias erstellen
sqlcl> alias whoami = select sys_context('userenv', 'session_user') from dual;
sqlcl> alias usersource = select * from user_source s where upper(s.text) like upper('%' || :1 || '%)';
sqlcl> alias emp1 = select * from emp where ename = :ENAME order by empno;
sqlcl> alias emp2 = select * from emp where job like '%'||upper(:JOB)||'%' and ename like '%'||upper(:ENAME)||'%' order by empno;

Aliasse auflisten
sqlcl> alias

Inhalt des Alias anzeigen
sqlcl> alias list usersource

Alias ausführen
sqlcl> whoami 
sqlcl> usersource <MEIN_SUCHTEXT>
sqlcl> emp1 KING
sqlcl> emp2 CLERK A

Alias exportieren
sqlcl> alias save whoami.xml

Alias importieren
sqlcl> alias load path/to_my/whoami.xml

Alias entfernen
sqlcl> alias drop whoami

Sehr hilfreiche Blogposts findet man unter:

Aliases with sdsql and simpler CTAS

SQLcl Aliases With Variables

SQLcl ALIAS – because you can’t remember everything.

Kommentare

Noch keine Kommentare zu diesem Beitrag.