relation tableName does not exist - PostgreSQL

I have a database named mimic on my postgres DB . I'm trying to execute this command :

select hadm_id from admission_ids where hadm_id in (select distinct on (subject_id) hadm_id from (select * from admissions order by admittime) tt

but I receive this error : relation "admissions" does not existWhen I modify the query by changing admissions to mimic iii.admissions it works. knowing that mimic iii is the schema , when I type this query this is the result that appears:

SELECT table_name FROM information_schema.tables WHERE table_schema = 'mimiciii'; table_name
-------------------- admissions callout caregivers datetimeevents ...

My question is what can I do to make the user type only the name of the table without using the schema.tableName ?

1 Answer

My question is what can I do to make the user type only the name of the table without using the schema.tableName ?

By putting the schema into your search_path.

Besides SET search_path TO ... which is valid for the duration of the session, it can be made permanent per user with ALTER USER username SET search_path='...', or per database with ALTER DATABASE dbname SET search_path='...'.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like