show_table
import TabItem from "@theme/TabItem"; import Tabs from "@theme/Tabs";
SHOW TABLES
We have currently generated a table called book
within the bookshop
database. To see all of the tables that have been created, use the SHOW TABLES
command. The SDK also includes methods for retrieving a list of all tables in the database.
<Tabs defaultValue="Python" values={[ { label: "cURL", value: "cURL" }, { label: "Python", value: "Python" }, { label: "JavaScript", value: "JavaScript" }, { label: "Golang", value: "Golang" }, ]}
curl --location 'https://api.xian.glitter.link/blockved/glitterchain/index/sql/query' \
--header 'Content-Type: text/plain' \
--data '{
"sql": "SHOW TABLES"
}'
The Python SDK provides a list_tables()
method to return a list of tables under the database.
db = client.db(mk)
rst = db.list_tables(table_keyword="", database="bookshop")
for row in rst["tables"]:
print(row)
The JavaScript SDK provides a listTables()
method to return a list of tables under the database.
const db = client.db(mk);
await db.listTables({
table_keyword: "",
database: "bookshop",
});
The Golang SDK provides a ListTables()
method to return a list of tables under the database.
resp, err := glitterClient.ListTables(ctx, "", "", "bookshop", nil, nil)
SHOW CREATE TABLE
If we need to see the precise structure of a table, we may use SHOW CREATE TABLE
. For example, you can see the specific structure of the table we created for books in the following example.
<Tabs defaultValue="Python" values={[ { label: "cURL", value: "cURL" }, { label: "Python", value: "Python" }, { label: "JavaScript", value: "JavaScript" }, { label: "Golang", value: "Golang" }, ]}
curl --location 'https://api.xian.glitter.link/blockved/glitterchain/index/sql/query' \
--header 'Content-Type: text/plain' \
--data '{
"sql": "SHOW CREATE TABLE bookshop.book"
}'
The Python SDK provides the function show_create_table
to view the specific structure of a table
db = client.db(mk)
rst = db.show_create_table('bookshop', 'book')
The JavaScript SDK provides the function showCreateTable
to view the specific structure of a table
const db = client.db(mk);
const res = await db.showCreateTable("bookshop", "book");