DBeaver中information_schema.columns查询无法运行的问题排查求助
Let's break down your problem step by step, since you mentioned the query works in SQL Server tools but fails in DBeaver 4.2.0, and you need to export all column metadata for your database tables.
First: Verify the Query's Correctness
The information_schema.columns view behaves slightly differently across database systems, so let's rule out script issues first:
- If you're using SQL Server: The
table_schemafield refers to the schema name (likedboby default), not the database name. If you intended to filter by database, usetable_cataloginstead:
Double-check thatSELECT * FROM information_schema.columns WHERE table_catalog = 'your_database_name';'schemaname'matches the actual schema your tables are stored in (runSELECT DISTINCT table_schema FROM information_schema.tables;to list available schemas). - If you're using MySQL/PostgreSQL: Your original query is syntactically correct—
table_schemadoes refer to the database/schema name here. So the issue is likely with DBeaver itself.
Next: DBeaver 4.2.0 Limitations & Potential Bugs
DBeaver 4.2.0 is a very old version (released back in 2017). Over the years, the DBeaver team has fixed dozens of bugs related to:
- Compatibility with newer database drivers
- Parsing and executing
information_schemaqueries - Metadata retrieval for various database systems
It's highly probable that your issue stems from an unpatched bug in this outdated version.
Solutions to Fix the Query & Export Your Column Data
Option 1: Upgrade DBeaver (Recommended)
Upgrading to the latest stable DBeaver version will almost certainly resolve the query issue, plus you'll get improved export functionality. After upgrading:
- Re-run your original (or corrected) query to confirm it returns results.
- Once you have the full column list in the results pane, right-click > Export Results and choose your preferred format (Excel, CSV, JSON, etc.).
Option 2: Work Around the Issue Without Upgrading
If you can't upgrade right now:
- Use database-native metadata queries instead of
information_schema:- SQL Server:
SELECT * FROM sys.columns;(join withsys.tablesif you need full table names) - MySQL: If your original query fails, try
SHOW FULL COLUMNS FROM schemaname.table_name;for individual tables, then combine results manually or via a batch script. - PostgreSQL:
SELECT * FROM pg_catalog.pg_attribute WHERE attrelid IN (SELECT oid FROM pg_catalog.pg_class WHERE relnamespace = (SELECT oid FROM pg_catalog.pg_namespace WHERE nspname = 'schemaname'));
- SQL Server:
- Use DBeaver's built-in export tool: Skip writing SQL entirely. Right-click your target schema/database in the left navigation panel > Export Data. In the wizard:
- Select "Metadata export" (or choose to export table data with column headers—adjust based on your needs).
- Pick your output format and follow the prompts to export all column details for every table.
Final Note
If after verifying the query and upgrading DBeaver the issue persists, it might be a rare edge case bug—but given the age of 4.2.0, upgrading is the most reliable fix.
内容的提问来源于stack exchange,提问作者mbahonen




