A
A
Alexander Nikulshin2018-06-13 17:47:47
PostgreSQL
Alexander Nikulshin, 2018-06-13 17:47:47

How to remove quotes from table and column names in PostgreSQL?

I used to work with MySQL and MsSQL subd, I decided to use PostgreSQL in the project.
In MySQL, you could use a query like this:

cmd.CommandText = "SELECT * FROM Users WHERE UserName='"+UserName.Text+"' AND Pass='"+Pass.Password+"'";

But in Postgres, you need to write the names of columns and tables in quotation marks:
cmd.CommandText = "SELECT * FROM public.\"Users\" WHERE \"UserName\"='"+UserName.Text+"' AND \"Pass\"='"+Pass.Password+"'";

Could you tell me if it is possible to get rid of the name in quotation marks? Well, it's very tiring.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Nikulshin, 2018-06-13
@xasya89

If I write without quotes, it gives an error: 42703 column 'username' does not exist Found
an article: https: //stackoverflow.com/a/postgresql-query-syntax ... , but if I write users without register, then quotes are not needed

A
Alex Plotnikov, 2018-06-13
@TrueDevs

there is no need for quotes at all, here is a copy-pasted example of a request from my working site

insert into users
            (user_email, user_password, user_role, user_login)
            values (?,?,?,?)
        ';

sorry, didn't see the C# tag (

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question