Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 157695
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T10:32:59+00:00 2026-05-11T10:32:59+00:00

Earlier I had asked the question: Where (or how) should I define the schema

  • 0

Earlier I had asked the question:

Where (or how) should I define the schema in a select statement when using PostgreSQL?

The answer I accepted was to modify the search_path for the connecting user so that the schema need not be specified in the SQL. However, now I wonder if I should always specify the schema in SQL rather than allow the schema to be automatically inferred by the search path. This seems like it would be a safer approach and would be more portable to other databases.

This question is different than the previous one in that I want to know what the best practices are for defining the schema in SQL, rather than how it can be done.

Should the schema always be explicitly defined in the SQL statement?

** Note: I would not hard code the schema name but would allow it to be configurable through the Web.config file so that the schema could change from one installation to another. **

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T10:33:00+00:00Added an answer on May 11, 2026 at 10:33 am

    It’s a bad practice to hardcode schema into SQL statements.

    You should keep it in the application settings and issue SET search_path after connecting to the database.

    If your application is used by multiple users with their own schemas, your life will be much easier if you don’t hardcode schema name into SQL.

    In other words,

    string query = 'SELECT * FROM ' + ConfigurationManager.AppSettings.Get('schema') + '.table'; 

    is a bad way;

    SQLCommand('SET search_path = ' + ConfigurationManager.AppSettings.Get('schema'), connection).ExecuteNonQuery(); string query = 'SELECT * FROM table'; 

    is a good way.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know I asked a related question earlier. I just had another thought. using
I had asked an earlier question which did not get any replies. Basically I
i had asked earlier about the same kind of question but that was in
I asked a question earlier about which language to use for an AI prototype.
I asked a question earlier , and got an excellent response, but, being a
Sorry folks but I asked a question earlier and perhaps did not explain myself
I had asked earlier in SO, how to wrap the multiple column in single
Hello nice computer persons, Per to a question I had earlier concerning accessing the
I wasn't sure how to word the question but I would like to step
5-6 years ago when i was in school, I had C as my programming

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.