Tagged Questions
An acronym for "Structured Query Language" (it's not the name of a specific DBMS product), SQL can be used in relational database management systems (RDBMS) to query, update, delete, and insert data as well as modify the structure of the database. It can also be used to manage schemas and data ...
0
votes
0answers
5 views
Missing 'tool' in SQL Developer
At my work we used to use MS Access to query on information in a database.
Now we are forced to use SQL developer to create query's and export data from a database.
In MS Access there was a Tab ...
-2
votes
1answer
15 views
Is it completely pointless to use NOT NULL after DATE types?
From my current knowledge and experience, it is not possible to insert NULL into a DATE type, so what would be the point in declaring NOT NULL at table creation?
I see this quite often throughout ...
1
vote
2answers
22 views
Nearest value for each foreign key
I have a table with a primary key, timestamp, value, foreign key. I would like to find the nearest value to a timestamp for each of the foreign keys in a list.
Unfortunately, the gap from the given ...
0
votes
1answer
10 views
Is there a more efficient way of using a match score in MySQL full text search?
SELECT i.*, MATCH(i.description, i.keywords) AGAINST ("searchterm") AS score
FROM items AS i
WHERE i.instock=1
AND MATCH(i.description, i.keywords) AGAINST("searchterm")
...
2
votes
1answer
32 views
Postgresql query slowed with table growth
I have a very simple table in Postgresql, and need some guidance to speed up my queries. Recent large expansion of the data in the table has made everything grind to halt.
Table body_feature:
...
0
votes
1answer
13 views
MySQL foreign key error
I need to update rows in a child table,but I am getting following error while I run the code,
Company Table
CREATE TABLE `company`
(
`Company_id` int(11) NOT NULL AUTO_INCREMENT,
`Company_name` ...
2
votes
1answer
28 views
Generate Backup list
I have the query below that returns all databases and full backup history with the last backup date and device name. I am trying to modify the query to only return all the databases and just the last ...
0
votes
0answers
14 views
Design database for payment gayeway like 2checkout? [on hold]
I am working on 2checkout api . I need to store data provided by 2checkout api.Storing data of ORDER CREATED event is simple but How do i handle events like recurring stop , recurring failed, ...
-1
votes
1answer
35 views
How to compare a result of a query to a number? [on hold]
I have a query that return selects a table and returns one column with a number, and I want to know if the result is > 0.
SELECT * FROM Table WHERE
(SELECT amount from Table2) > 0
...
1
vote
2answers
29 views
Get row from table for last date before date parameter if no row for date parameter or entries null
I have table, which holds the exchange rates for currencies. There is also a Date column, which holds the currency exchange rates acquisition date.
For some dates there is a row, but no currency ...
-3
votes
2answers
95 views
How to calculate the hours worked by all employees in a day?
vinay_hours
id cico
1 2014-02-20 10:31:00.503
1 2014-02-20 13:00:00.503
1 2014-02-20 15:31:02.503
1 2014-02-20 19:00:02.503
2 2014-02-20 10:00:02.503
2 2014-02-20 18:31:02.503
expected ...
1
vote
0answers
15 views
Setting up triggers based on exposed columns in a view's source table
I have a table where I want to do a AFTER UPDATE trigger if one of the columns modified was in a specific view
CREATE VIEW [dbo].[iv_EmployeesView]
AS
SELECT EMPLOYEE_GUID AS EmployeeGuid,
...
-2
votes
1answer
44 views
How to prevent duplicated records when applying ORDER BY NEWID() to fetch them randomly? [on hold]
I tried using the solution provided in http://stackoverflow.com/questions/1117761/sql-query-to-return-rows-in-random-order to fetch random records in my query. But I have to add NEWID() to the list of ...
1
vote
2answers
43 views
SQL Select query with postgresql
I'd like to find all rows if is shows even once a particular value with postgresql
For example :
id TIT_CODE CLI_NOM CLI_PRENOM CLI_ENSEIGNE
1 M. DUPONT Alain A
2 M. ...
1
vote
0answers
20 views
Upgrading the SQL Server version
My SQL Server version at home is 661 and at my school's is 655, so every time I try to open my web's SQL Server database at school it says there is an error:
So I thought that uploading the SQL ...
-2
votes
0answers
34 views
Best Isolation Level to avoid deadlocks in SQL Server
I need to execute an update statement over a SQL Server table. This table is used by another process at the same time. Because of that, sometimes deadlocks occurs. Which isolation level do you ...
2
votes
2answers
93 views
UPDATE table with another table data
I want to update the table car_check field fencing.(total 40 rows).I also use postgis function.
I think it's a little difficult.Any suggestions?
The code is the first carid example.
UPDATE car_check ...
0
votes
1answer
14 views
Select permission to each table
I have three schemas Production, HRecourse and Sales,tables in every week create and drop , I have six Users P_User1, P_User2, HR_User1, HR_User2 and S_User1 and S_User2. I have to grant then how i ...
0
votes
0answers
19 views
Combine a running balance SQL statement as a column
I have two Select Statements which are collecting data from 1 table, one is a totals select statement. Could anyone assist me with combining them into 1 statement? Any assistance is appreciated
...
0
votes
0answers
13 views
Free space of mdf and ldf does not match with database free space
In SSMS i saw file size related properties and found below details for one database.Here values does not match with other properties. Here size of the mdf, ldf and total size matches with other values ...
0
votes
0answers
12 views
MySQL: Updating a column referenced by two foreign keys in the same table leads to foreign key constraint failure [duplicate]
MySQL 5.5
I have a simple InnoDB table:
CREATE TABLE `T` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`deleted` bigint(20) unsigned NOT NULL DEFAULT '0',
`other` varchar(32) DEFAULT ...
2
votes
2answers
60 views
Order of returned record with IN statement postgres
I know that the order of returned records is not guaranteed with the IN statement for Pstgres. For example if I do this:
SELECT "users"."id" FROM "users" WHERE "users"."id" IN (13589, 16674, 13588)
...
2
votes
0answers
27 views
Is it possible to replicate wide table in MS SQL?
The reason of me using sparse columns is to overcome limit of 1024 columns in a table (I know that generally it's not a good reason and there are downsides, but in my situation it's good option ...
0
votes
0answers
15 views
postgres database program to save sql templates and search where used it
I have a postgres database with tables and functions build using sql templates. And I would like to use a database program to save these templates and search where I used it.
What i want to do is to ...
0
votes
1answer
34 views
Executing a SQL Job only once a month and after completion of a specific job
Let me better explain. My first job executes every 15 minutes (top of the hour, 12:15, 12:30 and 12:45). It does this for every day of the week.
I have a second job that runs at 1:30 AM on the first ...
0
votes
2answers
51 views
Select * on inner join with common columns
I have 3 tables (mysql db) on which I want to do an inner join. The problem is that these tables have common columns. I know I could use aliases to differentiate them (select A.x as Ax, B.x as Bx, C.c ...
0
votes
1answer
18 views
Select command denied after importing a view [on hold]
I imported a view from our development server into my localhost, but when I try to view the table in Sequel Pro I'm getting the following error:
SELECT command denied to user ''@'%' for column ...
...
1
vote
1answer
41 views
Selecting distinct records
I have a user relation to address (1 to 1).
So the address has two types which is a type column.
One is the VerifiedAddress and the other one is the SearchAddress.
So the user who had verified his ...
1
vote
0answers
39 views
SQL Server 2012 Database Engine Configuration Storage type Raid
I just inherited a Server that I have to rebuild for SQL Server 2012, I was wondering what would be the best disk configuration for the database engine.
This is what I have:
6 x 300GB 10k:
2 x 1TB ...
0
votes
1answer
37 views
Can't get rid of “temporary; Using filesort”
I can't get rid-off "temporary; Using filesort" when ordering columns from the second table
explain SELECT *
FROM post
JOIN post_plus
ON post_plus.news_id = post.id ...
-3
votes
0answers
38 views
I am getting error messages anytime I try to insert data in to SQL Server 2012 [closed]
Msg 547, Level 16, State 0, Line 1
The INSERT statement conflicted with the FOREIGN KEY constraint "FK_Address_ArtistAddress". The conflict occurred in database "MusicMania", table ...
1
vote
1answer
58 views
MySQL with slow queries
I have a website running on Wordpress Multisite + Woocommerce with over 5700 users on a Nginx + Apache server. I recently experienced some down time but didn’t get any errors, just a blank page.
I ...
0
votes
1answer
37 views
What is the correct name and significance of EAV table pivot?
I've been forced to use a very uncomfortable structure for a table. After trying to up similar examples, I've discovered the EAV, which seems almost like a pivot of said structure. The attribute order ...
-1
votes
0answers
9 views
Failure sending ssrs subscription report [closed]
Failure sending mail: An error has occurred during report processing.Mail will not be resent.
2
votes
1answer
32 views
SQL Profiler - Insert values?
I setup an SQL profiler to run, but I am not seeing any values for updates/inserts. Is there a way to see them?
All I see is stuff like this:
insert into some_tbl(id, col1, col2, col3) values ( @P0 ...
1
vote
1answer
59 views
Optimizing Postgres query
I've got a one to one relation from users to addresses table.
Where one user can have one search address and one verified address.
I've got two indexes on addresses table :
Index on state field
...
2
votes
1answer
23 views
Understanding postgres reason for picking this query plan
I ran a query:
select * from orderline where orderid = 12345 and status > 0
that gave me the following plan:
Bitmap Heap Scan on orderline (cost=286370.00..531410.78 rows=76372 width=155)
...
1
vote
1answer
33 views
Create database before restore multiple files
I've several database, most of them have multiple files (both data and logs) and multiple diff and trn backups. I've already a restore script (scheduled and working on other server) that takes all the ...
1
vote
0answers
31 views
SQL command in stored procedure continue on error
To perform Checkdb on all database of server i am using a stored procedure which loops over a view which contains list of databases in server and the stored procedure performs checkdb on all databases ...
0
votes
1answer
63 views
How index work in oracle? [duplicate]
I want to understand :
How index work in oracle.
How they are stored in the disk.
How they increase the efficiency of a query?
By third point I means how Index contribute to the efficiency of ...
1
vote
0answers
14 views
WMI event alerts
I am trying to understand WMI event alerts and have implemented a mirror with alerts on DATABASE_MIRRORING_STATE_CHANGE such that all database failover if the state is either 7 or 8 (manual failover ...
0
votes
2answers
32 views
Separating a date column in Access into Month, Day and Year while keeping the new columns ordered by a seperate column(primary key)
I have a column titled DateOpen which lists the date files were opened in d/m/yyyy format. I want to split the entries in that column into new columns titled MonthOpen, DayOpen and YearOpen while ...
1
vote
2answers
54 views
How can I dynamically alias columns?
I have a table (not designed by me) which has 20 variably named columns. That is, depending on what type of record you are looking at, the applicable name of the column can change.
The possible ...
0
votes
2answers
43 views
How to store a database table in multiple disks with assigned ratio?
I am going to deploy database tables to multiple disks.
My database layout would be like following example:
There are 3 tables (Customer, Order, Product) and 4 disks (disk_A, B, C, D).
Customer: 5% ...
1
vote
1answer
35 views
Error while importing sql - Specified key was too long; max key length is 1000 bytes
I am trying to import an sql file which shows me the following error:
Error
SQL query:
-- --------------------------------------------------------
--
-- Table structure for table `users`
--
CREATE ...
0
votes
0answers
15 views
WHY Extended Distributed Transactions (XA) NEEDED
I want to know what is Extended Distributed xa Transactions.
why it is needed.
if we enable this for another database on any existing sql server will it impact my existing databases.
0
votes
0answers
25 views
What is the name of the DB model implemented by NoSQL DBs? [closed]
I have been reading to understand the "behind the scenes" of different DBs.
From what I understand, each DB and system is structured in a way that implements a database model.
For example, ...
0
votes
1answer
40 views
Where can I get best resources to learn sql? [duplicate]
I am very new to the databases just have basic knowledge about it.
I want to learn sql language and dont know where to start. Please help me to start with it.
And what is the difference between ...
2
votes
1answer
29 views
redundant foreign keys in PostgreSQL - are there any indexing benefits?
Note: this is not the same as this SO question which is about adding redundant information in the tables themselves.
Does the final statement in the below series of statements buy me anything in ...
0
votes
2answers
120 views
Database Server down [closed]
I am an application developer and our firm doesn't have a dedicated DBA. Now, I am asked to see why our database servers were down? I know how to write queries and I want your help in knowing what ...