how to avoid duckdb create table columns names with quotes on database? (in case,…
- User
how to avoid duckdb create table columns names with quotes on database? (in case, PostgreSQL)
- Assistant
To avoid DuckDB creating table column names with quotes when working with PostgreSQL, you have a few options:
1. Use standard SQL identifiers Ensure your column names follow standard SQL naming conventions:
- Start with a letter or underscore
- Use only letters, numbers, and underscores
- Avoid SQL reserved words
- Keep names lowercase
-- This will create columns without quotes CREATE TABLE my_table ( user_id INTEGER, first_name VARCHAR, created_at TIMESTAMP );2. When importing from PostgreSQL to DuckDB If you're importing data from PostgreSQL that has quoted identifiers, you can normalize them during the import:
-- Instead of preserving original quoted names CREATE TABLE new_table AS SELECT "User ID" AS user_id, "First Name" AS first_name, "Created At" AS created_at FROM postgres_table;3. Configure DuckDB settings You can set DuckDB to be less strict about identifier quoting:
SET preserve_identifier_case = false;4. When connecting to PostgreSQL from DuckDB If you're using DuckDB's PostgreSQL extension, you can alias columns during queries:
INSTALL postgres; LOAD postgres; SELECT "problematic column" AS clean_column_name FROM postgres_scan('host=localhost user=myuser password=mypass', 'public', 'mytable');The key is to establish clean naming conventions early in your workflow and avoid special characters, spaces, or mixed case in column names that would require quoting.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.