以下是一些可以在PostgreSQL的information_schema中执行的SQL查询:
SELECT datname FROM information_schema.schemata;
SELECT table_name FROM information_schema.tables WHERE table_schema = 'public';
SELECT column_name, data_type, is_nullable FROM information_schema.columns WHERE table_name = 'your_table_name';
SELECT tc.table_name, kcu.column_name
FROM information_schema.table_constraints AS tc
JOIN information_schema.key_column_usage AS kcu
ON tc.constraint_name = kcu.constraint_name
WHERE constraint_type = 'PRIMARY KEY';
SELECT tc.table_name, kcu.column_name, ccu.table_name AS foreign_table_name, ccu.column_name AS foreign_column_name
FROM information_schema.table_constraints AS tc
JOIN information_schema.key_column_usage AS kcu
ON tc.constraint_name = kcu.constraint_name
JOIN information_schema.constraint_column_usage AS ccu
ON ccu.constraint_name = tc.constraint_name
WHERE constraint_type = 'FOREIGN KEY';
SELECT indexname, indexdef FROM pg_indexes WHERE tablename = 'your_table_name';
SELECT table_name FROM information_schema.views;
SELECT routine_name FROM information_schema.routines WHERE routine_type = 'FUNCTION';
这些是一些常见的SQL查询,可以帮助您了解数据库中的元数据信息。您还可以根据需要编写自定义的查询来获取更详细的信息。