sql

Remove Unique constraint on a column in sqlite database

家住魔仙堡 提交于 2021-02-19 02:24:06
问题 I am trying to remove a UNIQUE constraint on a column for sqlite but I do not have the name to remove the constraint. How can I find the name of the UNIQUE constraint name to remove it. Below is the schema I see for the table I want to remove the constraint UNIQUE (datasource_name) sqlite> .schema datasources CREATE TABLE "datasources" ( created_on DATETIME NOT NULL, changed_on DATETIME NOT NULL, id INTEGER NOT NULL, datasource_name VARCHAR(255), is_featured BOOLEAN, is_hidden BOOLEAN,

Recently executed SQL not in V$SQL

独自空忆成欢 提交于 2021-02-19 02:22:45
问题 Under what circumstances does a select query not appear in the V$SQL view? For example, if I run this: select /*findme*/ * from T ... And then immediately afterward run this: select * from v$sql where sql_text like '%/*findme*/%'; Under what circumstances would I get no rows returned? And under those circumstances can I force a query's info to be recorded in V$SQL? 回答1: Under what circumstances does a select query not appear in the V$SQL view? One situation is on a Real Application Cluster

Mysql select for update - it is not locking the target rows. How do I make sure it does?

守給你的承諾、 提交于 2021-02-19 02:22:26
问题 So the syntax for select for update is something like SELECT * //1st query FROM test WHERE id = 4 FOR UPDATE; UPDATE test //2nd query SET parent = 100 WHERE id = 4; I am guessing the locking part is the first line. So when the first set of queries executes, I should not be able to select and modify the row with id = 4 (it is primary key by the way). However, I am still able to select row with id = 4 before I update anything, meaning another thread could probably come in and try to select and

How do I join 4+ tables in Access with a combination inner/outer?

为君一笑 提交于 2021-02-19 01:40:10
问题 I have not been able to find a way to join 4 or more tables using outer join in MSAccess. It works in SQL Server, but not Access. I don't believe it is possible. I have tables A, B, C, D and E. I need to join the tables like so: A left outer join B A left outer join C A inner join D B inner join E Access won't let you use conventional joins in the where clause when you use LEFT/RIGHT/INNER JOINS in the FROM clause. If you do, I get very, very vague errors like "JOIN expression not supported"

How do I SQL query for words with punctuation in Postgresql?

情到浓时终转凉″ 提交于 2021-02-18 22:45:23
问题 If I have strings/phrases like this stored in the database: What are Q-type Operations? Programmer's Guide A.B.C's of Coding Is there a way to pass a query parameter in like "Programmers" or "abc" or "q-type" and have it find "Programmer's" , "A.B.C" and "Q-type" ? 回答1: tsvector Use the tsvector type, which is part of the PostgreSQL text-search feature. postgres> select 'What are Q-type Operations?'::tsvector; tsvector ------------------------------------- 'Operations?' 'Q-type' 'What' 'are'

convert timedelta object to time object

旧城冷巷雨未停 提交于 2021-02-18 22:23:05
问题 When fetching rows from my database containing time ex 15:15:15 h/m/s. I get those in timedelta objects, i want them in time object so I later can combine them with a date object and get a datetime object. for row in results: startDate = row['startDate'] StartTime = row['startTime'] myListStartDate.append(datestart) myListTimeStart.append(startTime) When i put all the startTimes in a list and prints the list i get datetime.timedelta(0, 54900). So how do convert the timedelta to a time object

MS SQL 2012 : In SQL Shift columns to left side if column contains 0

微笑、不失礼 提交于 2021-02-18 22:21:42
问题 I need to shift data(columns) to left side if first columns(left side columns) have 0 value and NULL should be added in right side columns. Once non-zero value found in any columns then 0 value in later column should remain as it is. Input Data:- cust_id month1 month2 month3 month4 month5 c1 100 200 300 400 500 c2 0 0 50 250 350 c3 0 0 100 0 0 c4 100 0 100 0 500 c5 0 0 0 0 0 Expected Output Result:- cust_id month1 month2 month3 month4 month5 c1 100 200 300 400 500 c2 50 250 350 NULL NULL c3

How can I identify columns when SELECTing from multiple tables with JDBC?

冷暖自知 提交于 2021-02-18 22:13:05
问题 I have two tables that I join on the id-column, they look like: +-------+ | users | +----+--+---+ | id | name | +----+------+ +-------+ | posts | +-------+------+---------+ | id | user_id | message | +----+---------+---------+ And now I want to select all posts and include the username, with: SELECT * FROM posts, users WHERE user_id = users.id And then I try to get the values with: ResultSet rs = // SQL if(rs.next()) { rs.getInt("posts.id"); ... } But I get SQLException when executing rs

How can I identify columns when SELECTing from multiple tables with JDBC?

醉酒当歌 提交于 2021-02-18 22:09:52
问题 I have two tables that I join on the id-column, they look like: +-------+ | users | +----+--+---+ | id | name | +----+------+ +-------+ | posts | +-------+------+---------+ | id | user_id | message | +----+---------+---------+ And now I want to select all posts and include the username, with: SELECT * FROM posts, users WHERE user_id = users.id And then I try to get the values with: ResultSet rs = // SQL if(rs.next()) { rs.getInt("posts.id"); ... } But I get SQLException when executing rs

Default values for columns in Big Query Tables

纵饮孤独 提交于 2021-02-18 21:09:30
问题 Is there a way to set default values for columns in tables in big query? I would like to set 'false' as a default value for a column of boolean data type. 回答1: A nullable column can (trivially) have a NULL default value, but there is no other notion of default in BigQuery (you either insert a particular value or omit the value and it will have the NULL value). That said, if you want to wrap your raw table in a View, you can map a NULL column value to any default that you like. 回答2: There is