[...]
exec_sql() { echo "$*" | \ bsqldb -q -h -t
'|-|' -S "$SERVER" -D "$DATABASE" -U "$USER" -P "$PASSWORD" }
to_html() { echo '
#;s#$# | #g' | \ sed
'/-*<\/td>\)*<\/tr>/{;s#.*# | |
while true; do read -p "> "sql> " QUERY
exec_sql "$QUERY" | to_html | w3m -dump -T text/html done }}}
If you just want CSV instead of tabulated output, replace | to_html
| w3m -dump -T text/html with e.g. | sed 's/|-|/;/g' | less (or
something similar). similar, or leave it out
altogether).
[...]
* list all tables in your database (from sysobjects):
database: {{{ > sql> sp_tables }}}
* list all kinds of stuff in your database: {{{ sql> select name,type from sysobjects }}}
* show the definition of a table (from
(this information comes from syscolumns): {{{ >
sql> sp_help tablename }}}
* show the definition of a view, stored procedure or similar
(from (this information comes from syscomments):
{{{ > sql> sp_helptext viewname }}}
[...]