以下是一些可以在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查詢,可以幫助您了解數據庫中的元數據信息。您還可以根據需要編寫自定義的查詢來獲取更詳細的信息。