Since Redshift does not support ALTER COLUMN, I would like to know if it’s possible to remove the NOT NULL constraints from columns in Redshift. Answer You cannot alter the table. There is an alternative approach. You can create a new column with NULL constraint. Copy the values from your old column to …
Sql server clustered index on multiple column with different sort direction
Can I have a clustered index created on multiple columns with different sort direction. For example Create Clustered Index IX_Name on Table1(Empid asc,empname desc,sal asc) If the answer is yes I am …
How to automate source control with Oracle database
I work in an Oracle instance that has hundreds of schemas and multiple developers. We have a development instance where developers can integrate their work before test or production. We want to have source control for all the DDL run in this integrated development database. Currently this is done through a pr…
Ambiguous column using JDBC but query works fine in database
I am connecting to a SQLite database through java using JDBC. Schema: WorkInfo(id, job, salary) Person(id, name) This query below runs fine in my database, but when I try it with JDBC: ResultSet …
How to return a value from a function if no value is found
I’m attempting to return 0.0 if the following function does not return anything: I’ve tried searching for it and found that COALESCE does not work. Does anyone have any ideas how to solve this? Table structure: Example data: Answer Here is the script I used. As you can see I run PostgreSQL 9.4.1. …
UPDATE order in PostgreSQL
I have a mysql command: update table_demo SET flag= 1 where flag=0 ORDER BY id ASC LIMIT 10 and need the same command in Postgres, I get this error: ERROR: syntax error at or near ‘ORDER’
Do I need a where clause in a conditional UPDATE?
We imported a lot of data from another table. Now I’m trying to correct some of them. I didn’t use ELSE because many rows have valid country. My question is to know whether I need to the WHERE clause to filter the rows that will be affected? The reason I’m asking this question is that, IR…
How to use between clause in select statement in codeigneiter
I’m trying to get data from database by taking one data row from one table and use those values as where condition. and then i tried pass json string to controller class. but i’m unable to reach this. how should i write this code This is code i used to get data. Answer Use this for between
Query with rownum got slow
I have got a table table with 21 millions records of which 20 millions meet the criterion col1= ‘text’. I then started iteratively to set the value of col2 to a value unequal to NULL. After I have mutated 10 million records, the following query got slow, that was fast in the beginning: I noticed t…
dash character in mysql MATCH
I have a table of documents numbered by year / series, like this: 13-201 (this would be document 201 in 2013). I want to do a MATCH AGAINST full text query for this table, so a user could grab a list …