I will outline a few DB2 tips and tricks.
You can see a list of all tables in the current database using the command select tablename from syscat.tables. syscat.tables is the name of the table in the syscat (system catalog) schema whose structure you can look up to see more traits of the database that you can query. You look up a table's structure through describe table <table name>
You can see the current date by querying a runtime table called sysdummy1 in the sysibm schema, as in select current date from sysibm.sysdummy1.
Similarly you can query the current schema through select current schema from sysibm.sysdummy1.
DB2 has this concept called schema, which groups together database objects like tables, indexes, triggers etc. This schema is the same as your login user name by default. You have to prefix the schema to your table name if you're querying a table from another schema.
You can look at all the schema present through select schemaname from syscat.schemata
You can change the current schema by using set current schema = '<schema name'>
You can see a list of all tables in the current database using the command select tablename from syscat.tables. syscat.tables is the name of the table in the syscat (system catalog) schema whose structure you can look up to see more traits of the database that you can query. You look up a table's structure through describe table <table name>
You can see the current date by querying a runtime table called sysdummy1 in the sysibm schema, as in select current date from sysibm.sysdummy1.
Similarly you can query the current schema through select current schema from sysibm.sysdummy1.
DB2 has this concept called schema, which groups together database objects like tables, indexes, triggers etc. This schema is the same as your login user name by default. You have to prefix the schema to your table name if you're querying a table from another schema.
You can look at all the schema present through select schemaname from syscat.schemata
You can change the current schema by using set current schema = '<schema name'>
No comments:
Post a Comment