Inserting with empty values in PostgreSQL causes error - sql

My table has three columns, but I'm only using one for most rows.
I'm trying to do a basic insert in PSQL, like so:
grouper=> INSERT INTO master_list VALUES ('Ebay',,);
But I'm getting a syntax error:
ERROR: syntax error at or near ","
LINE 1: INSERT INTO master_list VALUES ('Ebay',,);
^
Any advice or suggestions welcome!

Try
INSERT INTO master_list VALUES ('Ebay',null,null);
or
INSERT INTO master_list (fieldname) VALUES ('Ebay');

Related

how to insert values through select in ssms ? and i am getting error through which i tried

I tried inserting values into a table that I created but while inserting into them through select statement I am getting an error message
the code which I tried for insert is
create table dbo.watermarktable
(tablename varchar(255),
watermarkvalue datetime,
);
insert into dbo.watermarktable(tablename,watermarkvalue)
("reference_value", select max(created_date) from dbo.reference_value_genc);
but the values were not taken and thrown an error message
and the error message is
Incorrect syntax near 'reference_value'.
Msg 102, Level 15, State 1, Line 7
Incorrect syntax near ')'.
Completion time: 2021-10-28T14:29:43.2357252+01:00
You can either use VALUES or SELECT with INSERT INTO. So Change your insert like this
insert into dbo.watermarktable(tablename,watermarkvalue)
SELECT 'reference_value', max(created_date) from dbo.reference_value_genc;
Your syntax is a bit off, change it to this:
INSERT INTO dbo.watermarktable (tablename,watermarkvalue)
SELECT 'reference_value', max(created_date)
FROM dbo.reference_value_genc;

Inserting values into a hive table issue

I am attempting to insert values into a specific column in a hive table. The following query does not seem to work:
INSERT INTO table DQ_Rules_Status_Table_PROFILER (Load_TimeStamp) VALUES (2020-01-24) where Load_Ts rlike('Jan 24');
The error message received is as follows:
Error: Error while compiling statement: FAILED: ParseException line 1:86 missing EOF at 'where' near ')' (state=42000,code=40000)
UPDATE DQ_Rules_Status_Table_PROFILER SET Load_TimeStamp = '2020-01-24' WHERE Load_Ts rlike('Jan 24');

Missing select keyword in Oracle SQL

I am getting this error
SQL Error: ORA-00928: missing SELECT keyword
00928. 00000 - "missing SELECT keyword"`
when I am trying to insert like this
create table certf
(
certificate_id integer primary key,
certificate_name varchar(100) not null,
certificate_content varchar(300) not null
);
insert into certf (&certificate_id, &certificate_name, &certificate_content);
You are missing values actually:
insert into certf (certificate_id, certificate_name, certificate_content)
values (&certificate_id, &certificate_name, &certificate_content);
Notice that I also added the column list to the insert. This is a best practice.
If those are supposed to be values you're providing as substitution values, then you're missing the values keyword:
insert into certf values (&certificate_id,&certificate_name,&certificate_content);
But you need the string values to be in quotes:
insert into certf values (&certificate_id,'&certificate_name','&certificate_content');
and you should supply the column names too:
insert into certf (certificate_id,certificate_name,certificate_content)
values (&certificate_id,'&certificate_name','&certificate_content');
With you current code the parser is seeing that first list of - possible, but actually invalid in this case - identifiers, i.e column names; because it hasn't seen that values keyword yet. It's treated as something like:
insert into certf (42,some_name,some_content);
And having done that, and when it still doesn't see a values keyword or values list, it's expecting this to be an insert ... select construct instead. You could do it that way:
insert into certf (certificate_id,certificate_name,certificate_content)
select &certificate_id,'&certificate_name','&certificate_content' from dual;
But you aren't doing that. So it doesn't see the select either, and it throws the error you see.

ORA-00917: missing comma error, when column desc is having spanish words

insert into tab (ID, DESCRIPRION) values (1,'FARMACIAS PHARMACY´S');
getting following error.
ERROR at line 1: ORA-00917: missing comma
my description is in spanish language.
Please let me know, how to fix above error.
Try using the q-quote syntax for quoting a string...
insert into junk values ( 1, q'[FARMACIAS PHARMACY´S]' );
DESC is a keyword. Wrap it in double quotes
insert into tab (ID, "DESC") values (1,'ABC FRMACY´S');

mysql error 1064 when inserting

1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(country,ping,order) VALUES (China,1,1)' at line 1
this is my code
INSERT INTO
(country, ping, order)
VALUES
('China', '1', '1');
You're missing the Table Name. Try:
INSERT INTO MYTABLENAME (country,ping,order) VALUES ('China','1','1');
are ping and order text fields or numeric? if numeric remove the ticks from the 1's
INSERT INTO Tablename (country,ping,order) VALUES ('China',1,1)
could also be reserved word try:
INSERT INTO Tablename (country,`ping`,`order`) VALUES ('China',1,1)
Your insert statement is missing the table name:
INSERT INTO tbl_name (col_name,...) VALUES (expr,...)
you are missing table name. also make sure that those quotes are necessary