Clear Filters
Clear Filters

request a table with a capslock name

25 views (last 30 days)
xvwfx nvpkxqg
xvwfx nvpkxqg on 28 Feb 2022
Edited: Walter Roberson on 16 Aug 2024 at 20:47
conn = postgresql("x", "x", "x");
data = sqlread(conn, "SERIES");
Driver Error: ERROR: relation "series"
does not exist
LINE 1: SELECT * from SERIES
^
it won't find the table because it tries to find it in lowercase. "series"
well, this doesn't seem to work

Answers (1)

Sameer
Sameer on 16 Aug 2024 at 9:38
Hi
The error you are facing is related to how PostgreSQL handles case sensitivity in table names. By default, PostgreSQL converts all identifiers (such as table names) to lowercase unless they are wrapped in double quotes. This means that if your table was created with a name in uppercase or mixed case and quoted, you need to reference it exactly as it was created.
Here's how you can address this issue:
1. Check the Table Name in PostgreSQL: Make sure you know the exact case of the table name in your PostgreSQL database. If it was created with double quotes and a specific case (e.g., "SERIES"), you must reference it exactly as such.
2. Use Quoted Identifiers in Your Query: When writing your SQL query in your code, use double quotes around the table name to preserve the case sensitivity. Here's how you can modify your query:
data = sqlread(conn, '"SERIES"');
By using double quotes, you tell PostgreSQL to treat the identifier as case sensitive.
3. Verify Table Creation: If possible, verify how the table was created. If it was created without quotes, you should reference it in all lowercase. You can check this by querying the information schema:
SELECT table_name
FROM information_schema.tables
WHERE table_schema = 'public'; -- or your specific schema
This will list all tables in the specified schema, showing their actual names as stored in the database.
4. Adjust Table Creation if Needed: If you have control over the table creation and want to avoid this issue in the future, consider creating tables without quotes, which will make them case-insensitive and accessible with lowercase names.
By following these steps, you should be able to correctly reference and query your table in PostgreSQL from your application.
I hope this helps!
Sameer

Products


Release

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!