Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Using sqlline, how do you filter/find tables using the !tables command
I need to filter/find and list tables using the sqlline !tables
command.
For example, these are the type of queries i wish to fire
- Find out all the tables in a particular schema
s1
- All tables that start with t0
- All tables whose schema name ends with 20 and whose table name start with
x
- All the "table", not "views" in a particular schema
s19
- Get all the views in the system
All i see in the documentation is the following
tables — List all the tables in the database, schema, by pattern
Synopsis !tables
It mentions "by pattern" but no information on the pattern
1 answer
From the source code it seems the following is possible.
!tables <table name pattern>
!tables <schema name pattern> <table name pattern>
!tables <schema name pattern> <table name pattern> (<table type name>)*
So for the examples quoted above, this is how it would be done
!tables "s1" "%"
!tables "t0%"
!tables "%20" "x%"
!tables "s19" "%" "TABLE"
!tables "%" "%" "VIEW"
Note that filtering by the Catalog or Database doesn't seem to be possible.
0 comment threads