Database meta information
DB2Rest makes it very easy to view the database schema, all tables and views within an database schema as REST API. Optionally it will return all column information.
Schema Endpoint
The API endpoint for viewing the schema is /{dbId}/$schemas?columns=true
, where dbId
is the configured database identifier.
- cURL
- HTTPie
curl --request GET \
--url 'http://localhost:8080/v1/rdbms/pgsqldb/$schemas?columns=true' \
-H 'Accept: application/json'
http GET 'http://localhost:8080/v1/rdbms/pgsqldb/$schemas?columns=true' \
'Accept:application/json'
The response is shown below:
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 324
[
{
schema: "public",
name: "categories",
type: "TABLE",
columns: [
{
name: "category_id",
pk: true,
dataType: "int4"
},
{
name: "name",
pk: false,
dataType: "varchar"
}
]
},
...
]