Skip to content
Advertisement

How to delete duplicate entries?

I have to add a unique constraint to an existing table. This is fine except that the table has millions of rows already, and many of the rows violate the unique constraint I need to add. What is the …

sql while loop with date counter

I need to do something like this in sql: How can I do the above correctly in SQL? Basically, my startdate and enddate are strings and not datetimes because my business logic is referencing string column in another table with a date as the name of the column-But I need to loop through a bunch of columns, each column having

SELECT (* – some_columns) FROM TABLE in SQL

I have a table with many columns among which I’d like to omit a few alone in my ‘select’ query. Something like select (* – columns_to_be_omitted) from myTable. Is there a way to do this, other than listing all the other columns in the query? This is a one-time manual query, so I’m not that concerned about performance. Ease of

Efficient way to check if a SQL query will return results

I would like to write a query that simply returns 1 or 0 depending if there will be results. I am thinking to use this That’s the general premise. The final results will actually be a far more complex query, taking one to many parameters and the string built up and executed using sp_executesql My question is lets say the

Insert if not exists Oracle

I need to be able to run an Oracle query which goes to insert a number of rows, but it also checks to see if a primary key exists and if it does, then it skips that insert. Something like: Is this at all possible with Oracle? Bonus points if you can tell me how to do this in PostgreSQL

How can I print the SQL query executed after Perl’s DBI fills in the placeholders?

I’m using Perl’s DBI module. I prepare a statement using placeholders, then execute the query. Is it possible to print out the final query that was executed without manually escaping the parameters and dropping them into the placeholders? Thanks Answer See Tracing in DBI. The following works using DBD::SQLite but produces a lot of output: Output: <- prepare(‘SELECT … FROM

Advertisement