我该怎么做?
我知道为了获取每个表的名称,我必须使用
SELECT name AS table_name
FROM sqlite_schema
WHERE type = 'table'
但其余的对我来说是个谜。 你愿意帮助我吗?
谢谢!!!
刚刚有同样的问题,答案归结为“手动”(查看模式可视化或上述输入查询)。 >_<
SELECT 'Customers' AS table_name,
13 AS number_of_attribute,
COUNT(*) AS number_of_row
FROM Customers
UNION ALL
SELECT 'Products' AS table_name,
9 AS number_of_attribute,
COUNT(*) AS number_of_row
FROM Products
UNION ALL
SELECT 'ProductLines' AS table_name,
4 AS number_of_attribute,
COUNT(*) AS number_of_row
FROM ProductLines
UNION ALL
SELECT 'Orders' AS table_name,
7 AS number_of_attribute,
COUNT(*) AS number_of_row
FROM Orders
UNION ALL
SELECT 'OrderDetails' AS table_name,
5 AS number_of_attribute,
COUNT(*) AS number_of_row
FROM OrderDetails
UNION ALL
SELECT 'Payments' AS table_name,
4 AS number_of_attribute,
COUNT(*) AS number_of_row
FROM Payments
UNION ALL
SELECT 'Employees' AS table_name,
8 AS number_of_attribute,
COUNT(*) AS number_of_row
FROM Employees
UNION ALL
SELECT 'Offices' AS table_name,
9 AS number_of_attribute,
COUNT(*) AS number_of_row
FROM Offices;
一旦我们从给定表中添加或删除列,可能会导致错误答案,而不是定义固定值,而是使用以下内容:
SELECT "Customer" AS table_name,
(SELECT count(*)
FROM pragma_table_info('customers')) AS number_of_attributes,
count(*) AS number_of_rows
FROM customers;