2011-06-22 43 views

回答

3

我通常使用此查询对information_schema.tables

SELECT table_name 
FROM information_schema.tables 
WHERE table_type = 'BASE TABLE' 
    AND table_schema = 'public' 
ORDER BY table_name 

您可能要调整table_schema满足您的需求,但。该查询应该(AFAIK)在遵循标准的任何数据库中工作。

2

查看信息模式:​​。

+0

如何循环遍历所有表,然后处理表,如果我在information_schema.tables中查找,我仍然需要使用脚本来循环返回的结果并执行/处理每个表。在ms sql中,您可以在命令行(sqlcmd)中执行类似操作:sp_msforeachtable'delete from?'该命令将从数据库 – technomage

+1

@technomage中的所有表中删除列,您需要了解如何使用UNIX。 'psql -At -c'SELECT table_name FROM information_schema.tables'| xargs -n 1 ....' – Sean

相关问题