If you want to check if a table (or a column) exists avoid errors when trying to DROP or ALTER it, there's also the IF EXISTS syntax.
DROP TABLE IF EXISTS foo;
In addition, to create an alias that accepts one or more arguments, we can use bash functions.
Just type the following 4 lines in bash, with an Enter at the end.
vfind ()
{
echo "select table_name, remarks from all_tables where table_name ilike '%${1}%';" | vsql
}
Usage examples:
1) To find all tables name which include charecters “t2”, type: vfind t2
2) To find all tables name which include charecters “proj”, type: vfind proj
table_name | remarks
------------------------------------------+-----------------------------------------------------------
projections | Projection information
projection_columns | Projection columns information
projection_refreshes | Historical and current projection refreshes
projection_delete_concerns | Projections that may have delete performance concerns
rebalance_projection_status | Rebalance progress for relevant projections.
projection_recoveries | Recovery status per projection
projection_usage | Projection usage history
projection_checkpoint_epochs | Projection checkpoint epochs
projection_storage | Storage information on each Projection
deployment_projection_statements | Deployment projection statements from current DBD designs
deployment_projections | Projections to be deployed from current DBD designs
(11 rows)
3) To print a complete listing of all tables and views in your DB, type only: vfind
(Without any variables)
Answers
What's wrong with using V_CATALOG.TABLES or V_CATALOG.ALL_TABLES? Are you against using other system tables (i.e. V_CATALOG.COLUMNS)?
Other options ... You can use the vsql meta functions \d or \dt
Or try exporting the table:
If you want to check if a table (or a column) exists avoid errors when trying to DROP or ALTER it, there's also the IF EXISTS syntax.
DROP TABLE IF EXISTS foo;
In addition, to create an alias that accepts one or more arguments, we can use bash functions.
Just type the following 4 lines in bash, with an Enter at the end.
Usage examples:
1) To find all tables name which include charecters “t2”, type: vfind t2
2) To find all tables name which include charecters “proj”, type: vfind proj
3) To print a complete listing of all tables and views in your DB, type only: vfind
(Without any variables)