Mercurial > sqlpython
changeset 61:1eefe17b3630
adding more psql \d commands
author | catherine@cordelia |
---|---|
date | Thu, 03 Apr 2008 11:21:26 -0400 |
parents | 3828db4f3c94 |
children | 833e9d251da3 |
files | sqlpyPlus.py |
diffstat | 1 files changed, 23 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/sqlpyPlus.py Wed Apr 02 22:47:06 2008 -0400 +++ b/sqlpyPlus.py Thu Apr 03 11:21:26 2008 -0400 @@ -688,6 +688,12 @@ \o spool \p list \w save + \db _dir_tablespaces + \dd comments + \dn _dir_schemas + \dt _dir_tables + \dv _dir_views + \di _dir_indexes \? help psql''' commands = {} for c in self.do_psql.__doc__.splitlines()[2:]: @@ -703,11 +709,26 @@ self.onecmd('%s %s' % (commands[abbrev], args)) self.onecmd('q') except KeyError: - print 'psql command \%s not yet supported.' % abbrev + print 'psql command \%s not yet supported.' % abbrev + + def do__dir_tables(self, arg): + self.do_select("""table_name, 'TABLE' as type, owner FROM all_tables WHERE table_name LIKE '%%%s%%'""" % arg.upper()) + + def do__dir_views(self, arg): + self.do_select("""view_name, 'VIEW' as type, owner FROM all_views WHERE view_name LIKE '%%%s%%'""" % arg.upper()) + + def do__dir_indexes(self, arg): + self.do_select("""index_name, index_type, owner FROM all_indexes WHERE index_name LIKE '%%%s%%' OR table_name LIKE '%%%s%%'""" % (arg.upper(), arg.upper())) + + def do__dir_tablespaces(self, arg): + self.do_select("""tablespace_name, file_name from dba_data_files""") + + def do__dir_schemas(self, arg): + self.do_select("""owner, count(*) AS objects FROM all_objects GROUP BY owner ORDER BY owner""") def do_print(self, arg): 'print VARNAME: Show current value of bind variable VARNAME.' - if arg: + if arg: if arg[0] == ':': arg = arg[1:] try: