Reputation: 602
I have a SQL script like this which I run from the command line using psql
:
insert into "A"."B" values
(1, 'name=a', '[email protected]', 'K')
How do I convert it into INSERT
command inside a database?
INSERT INTO "A"."B" (first_column, second_c, third_c, fourth_1)
VALUES ('2', 'name=a', '[email protected]', 'K');
Also what does "A"."B"
do? I read somewhere that double quotes are needed when table name has Capitals. I seem to get an error with that when I run commands inside the database.
Upvotes: 0
Views: 1525
Reputation: 210
You can use this query where A is schema and B is table name.
INSERT INTO "A"."B" (first_column, second_c, third_c, fourth_1)
VALUES ('2', 'name=a', '[email protected]', 'K');
Upvotes: 1
Reputation: 25351
You said that your database name was DB
and your table name was B
.
You can simply use the table name alone:
INSERT INTO "B" (first_column, second_c, third_c, fourth_1)
VALUES ('2', 'name=a', '[email protected]', 'K');
If you want to include the database name, then use:
INSERT INTO "DB"."B" (first_column, second_c, third_c, fourth_1)
VALUES ('2', 'name=a', '[email protected]', 'K');
The double quotes are only required when the name of any entity (e.g. table, column, etc...) is a reserved word.
Upvotes: 1