INSERT INTO PostgreSQL
It's not the INSERT that is the problem, it is the invalid SQL that you are trying to issue. Try your insert first then a separate count(*) query, or if you are using PostgreSQL 9.1+ you can use Common Table Expressions and RETURNING
WITH ins AS (
insert into tableinfo ("table","date")
values ('Sell','24 August') RETURNING "table"
)
select count(*)
from ins;
cannot get simple PostgreSQL insert to work
Use 'auto dealer'
instead. PostgreSQL interprets "
as being quotes for identifiers, '
as being quotes for strings.
Also:
If this is a new project, just don't use mixed case tables; it is a
source of frustration later. Instead of being able to use any case in
your SQL statements, you must both quote the identifier name and get
the case correct.There is no need to specify
id
/DEFAULT
, you're
asking it to do what it would have done already. I haven't met a DBMS
that requires you to includecolumnName
/DEFAULT
if you want it to
put the default value in the column, so I don't think this extra KV
pair is going to make what is happening clearer to anyone reading
your code later.
Related Topics
Equivalent Function for Dateadd() in Oracle
Mysql: How to Copy Rows, But Change a Few Fields
What Is a Simple and Efficient Way to Find Rows with Time-Interval Overlaps in SQL
Sqlite Select with Condition on Date
Insert Select Statement in Oracle 11G
When to Denormalize a Database Design
How to Generate a Temporary Table Filled with Dates in SQL Server 2000
Finding Rows That Don't Contain Numeric Data in Oracle
Use Access SQL to Do a Grouped Ranking
What Is the Equivalent Postgresql Syntax to Oracle's Connect by ... Start With
How to Do Multiple Case When Conditions Using SQL Server 2008
Cannot Create an Instance of Ole Db Provider Microsoft.Jet.Oledb.4.0 for Linked Server Null
SQL Use Alias in Where Statement
Procedure or Function !!! Has Too Many Arguments Specified
How to Find a Table Having a Specific Column in Postgresql