Ignore errors in mysql by reading from some MySQL dump [duplicate] - sql

This question already has answers here:
Ignore mysql error messages when executing an sql file
(2 answers)
Closed 8 years ago.
I got an MySQL dump with ONLY insert statements. I tried to import it like this:
mysql> \. racktablesTabellen.sql
which always worked for me, till now because I got some errors I have to ignore. Can anybody tell me how to Ignore errors and just keep on with the entries when I got an sql dump with only insert statements ?

A possible solution is to remove the PRIMARY KEY from your table, import and add the PRIAMRY KEY again with ALTER IGNORE syntax.

Related

Got 'Enter values for precautions" popup in Oracle Developer [duplicate]

This question already has answers here:
How to avoid variable substitution in Oracle SQL Developer
(5 answers)
Closed 1 year ago.
I'm using Oracle Developer to execute the SQL queries. I got this popup:
Enter value for precaution
when I'm trying to execute an insert query. Does anyone know why I'm getting this popup?
It would be simpler to answer if you posted statement you ran.
Meanwhile, that's probably because insert contains & which indicates a bind variable. Something like this:
insert into test (name) values ('Is this what&precaution?');
What to do? Run set define off first, then run the insert.

What is the Postgresql SQL query analogous to 'USE database_name' from MySQL? [duplicate]

This question already has answers here:
How to switch databases in psql?
(15 answers)
Closed 3 years ago.
I have to execute a script from Java code which should create a database and then a table in that database. How do I do it in PostgreSQL?
CREATE DATABASE mydb
USE mydb // doesn't work for PostgreSQL
CREATE TABLE mytable (.....)
What SQL do we give for Step 2 in PosgreSQL?
Version : 9.5
Almost this question has been asked before (Difference Between Schema / Database in MySQL)
This has a reference to chapter 5.8 'Schemas': https://www.postgresql.org/docs/current/ddl-schemas.html
If your answer was 'how are schemas implemented under PostgreSQL', than this might be the correct answer. I think you cannot use use .., and you have to use mydb.mytable. (or set a search pattern SET search_path TO mydb,public;)

decipher this postgresql syntax? [duplicate]

This question already has answers here:
How can I comment special \ commands in PostgreSQL's psql commandline tool?
(5 answers)
Closed 8 years ago.
I have a query in an excel file that I inherited from the previous user/creator of the tool. The external connection is to a PostgreSQL database. Here's the line of script that I need to decipher so that I can hopefully adjust the date range for the query:
with
icon_date as (select max(icon.date::date)/* '1/1/2014'::date*/ as icon_date from pmm.icon)
...
pmm is the schema and .icon is the table name
My specific question is what this part means:
/* '1/1/2014'::date*/
I have no clue what surrounding a date::data type with /* */ would do in the first part of the query. Any ideas? I can post more of query if that would help.
That is just a comment and it will be ignored.
There are (at least) two ways to put comments into SQL:
everything after -- until end of line
everything between /* and */ (even spanning lines)
My guess is that this is code left over from testing, where instead of the max you would select some fixed date (because it is faster, or data was missing).

SQLite delete with table alias [duplicate]

This question already has answers here:
Sqlite delete query error
(3 answers)
Closed 9 years ago.
I am trying to alias a table in SQLite, for example by the following command: (it is from the book i am reading"Database Management Systems by Ramakrishnan")
DELETE FROM Students S WHERE S.sid=12546
This code gives a syntax error. Without aliasing, the following code works:
DELETE FROM Students WHERE sid=12546
But, if i want to alias the table, what should i do? Can anyone help?
Thanks
The DELETE statement operates on a single table and does not use a table alias. so you will have to use your query as :
DELETE FROM Students WHERE sid=12546
Update:
SQLite apparently doesn't support joins with the delete statement, as you can see on the Syntax diagrams. In short in SQLite, one DELETE command deletes from only one table. So aliasing is of no use

How can I remove the leading quote? [duplicate]

This question already has answers here:
CSV import in SQL Server 2008
(3 answers)
Closed 8 years ago.
I am using BULK INSERT to import a text file into a table.
The data imports OK but is quoted. for example
"1235","Bob Dylan","Dylan","Bob"
I have read a bit on this and have I created a format file using BCP that resolves the problem except the leading quote. ie:
"1235,Bob Dylan,Dylan,Bob
How can I remove the leading quote
In the past I have used an XML format file with a dummy row of 1 character length. Maybe someone else has a more elegant solution but that worked for me.