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 ...

learn more… | top users | synonyms (1)

1
vote
1answer
64 views

Very slow simple PostgreSQL query on RDS

I seem to be getting very slow queries on a medium sized RDS box (db.m3.medium, 3.7gb ram). This is across a table of 4,152,928 rows.. select sum(some_field) c from pages where pages.some_id=123 and ...
0
votes
1answer
29 views

PostgreSQL: how do I query over a column with a custom range?

I'm trying to write a query over a string column called grades_served that can have values such as k-5 1-5 5-9 The query could be for a specific grade or it could be a range with a start and end ...
0
votes
1answer
24 views

What are alternatives to Replication to distibute data (Microsoft SQL Server)

Is anyone knowledgeable of alternatives to SQL Server replication? I have a scenario where separate databases will share a lot of the same data which complex queries will match against. We want to ...
3
votes
1answer
53 views

Query with dynamic ranges in PostgreSQL based on status

We have a table with invoices classified per day, with normal invoices and void invoices (invoices that are voided, in our country we use the Spanish term "anuladas"). For example suppose that we have ...
0
votes
1answer
10 views

MYSQL testing string field contains another altered string field

I have this table : mysql> desc mytab; +------------+-------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | ...
-3
votes
0answers
58 views

how to query to get data from multiple tables [closed]

i'm having data like this in two tables i want like this The query I'm using right now is: Select A.TaskCode,A.SubTaskCode,A.TagNo,A.TruckNo,A.Location ...
0
votes
4answers
62 views

Use SQL or NoSQL? [closed]

I'm designing a system that checks a given website for any security vulnerabilities. The system includes a client (firefox plugin) and a server. The server does all the scanning while the client just ...
0
votes
1answer
32 views

Oracle: Replace corrupted first datafile

A datafile associated with a tablespace has been corrupted (got truncated to size 0). I don't mind losing the data, because I have a full DB dump which I can import. Now I want to replace this ...
2
votes
1answer
53 views

MS SQL - export tables to format compatible with PostgreSQL

We're using MS SQL Server 2005 at work and I want to export our data to PostgreSQL for testing. MS SQL Server has an export function but the only one that looks like it would work would be to export ...
11
votes
1answer
293 views

Resolving deadlock from 2 tables only related through indexed view

I have a situation where I'm getting deadlocks, and I think I've narrowed down the culprits, but I'm not quite sure what I can do to fix it. This is on a production environment running SQL Server ...
2
votes
1answer
60 views

TSQL- Column DataType Length

Can anyone please explain me the below one. I used the below query in getting the table columns info, but the max length seems to be x*2 of the actual col length. I mean if I have a col with datatype ...
0
votes
0answers
18 views

Select changes in table by date

I have following table schema name type id int key string count int date date url_id id with example data id key count date url_id 1 system 100 ...
0
votes
0answers
33 views

How to improve performance joining tables with no primary keys

Given two large tables of ~8,000,000 rows each. They are being joined on substrings of name address zipcode Naturally, the query is taking a long time. What are the best methods to improve it
0
votes
1answer
30 views

PostgreSQL : select columns inside json_agg

If I have a query like SELECT a.id, a.name, json_agg(b.*) as "item" FROM a JOIN b ON b.item_id = a.id GROUP BY a.id, a.name; How can I select the columns in b so I don't have b.item_id in the ...
3
votes
1answer
36 views

PostgreSQL seems to ignore RAISE EXCEPTION in a CTE

Using PostgreSQL 9.3 I have been trying to define an assert helper function to check for empty query results and similar things as follows: CREATE FUNCTION public.assert ( in_assertion boolean, ...
0
votes
1answer
17 views

Insert pictures [closed]

I need to create dictionary with pictures. I created database of words in mysql I tried to collect pictures of each word. How can insert pictures into tables?
0
votes
0answers
20 views

Installing database

I have created database in my system using mysql.I tried to use in one of my friend's system.How can install the database in other system?
1
vote
2answers
31 views

SQL view, how to append results from tableB with the results from tableA

I am using SQL server 2012. I would like to generate a sql view where I got all records from tableA. And below these results I would like to have the results from tableB. There are no relations ...
0
votes
0answers
28 views

eCommerce product table design - MySQL

I am designing database for an web application, I have designed the product and specification details database as follows, create table pr_size ( size_id int not null auto_increment, ...
0
votes
1answer
31 views

SQL Server 2012 Express SP1 install still not 11.1

I run the SQL Server 2012 Express SP1 install and it succeeds. After I have rebooted my computer, I do a select @@version But still I only have version 11.0.21600.64. I have tried this on two ...
0
votes
0answers
13 views

Redesign tables, multiple foreign key and related table to same table

Hello I have this database: Table Teams is used in each one table. Match table contains teamA and teamB and round contains team that win the SET and team that start the set. But I dont know how I ...
0
votes
1answer
9 views

Get devices with not driver assigned

I have this related tables: And I need to get those devices with no driver assigned, in other words the device returned on this query shouldn't be on driver_has_device table since it'll not have ...
-1
votes
4answers
210 views

Database/Storage engine suggestion for a project involving heavy inserts?

I am looking into a project which involves large number of inserts daily.I will have a list of user's (for example a user set of 500k ) , for which I need to monitor daily certain activities ...
0
votes
1answer
30 views

Can PostgreSQL results include the query?

I run the following command to run 2 queries in a sql file. Could be 1, could be 50 queries. Depends on the deployment. psql -U <username> -h <servername> -d <databasename> -f ...
1
vote
1answer
21 views

Postgres Update, limit 1

I have a postgres database which contains details on clusters of servers, such as server status (active, standby, etc). Active servers at any time may need to fail over to a standby, and I don't care ...
1
vote
4answers
109 views

Is it ok to change from full recovery to simple recovery in Sql Server

I have an old database - a users membership/role that was setup automatically by an ASP.Net 2 application years ago: The Sql Server version currently running is: Sql Server 10.5.1617 The users ...
0
votes
1answer
33 views

Finding Item's distribution over customer routes

Please help me to find a solution. I have two tables [CustomerMaster and SalesData] as shown below. CustomerMaster | CODE | NAME | ROUTE | DIVISION | |------|------------|-------|----------| ...
-1
votes
0answers
15 views

How to stop automatically row increment on sql server via FreeTDS, pyodbc

How can i stop automatically increment of rows in my sql server database table. The server connection established using FreeTDS, UnixODBC, Pyodbc. cursor.execute( "insert into Database1([image ...
-1
votes
3answers
54 views

Retrieve recently inserted 5 rows [closed]

I want to fetch recently inserted 5 rows from my table. I want to know the sql query for the same. My table is: table xyz ( id integer generated always as identity (start with 1 increment by 1), ...
0
votes
1answer
40 views

Join reorders results [duplicate]

Is there any particular reason why adding an additional join to an ordered table would reorder the result set? Using a left join on the existing result set table-valued function is similar to below ...
1
vote
0answers
61 views

Database Archival Process [closed]

I am designing a database archiving process - which is a automated process. Do you have any advice for how to accomplish these goals? Below are my thoughts : create another clone database ...
0
votes
2answers
42 views

Oracle conditional statements

I am making a report, and I am trying to do following: If the value of the field is NULL, output empty string. Another words, I don't need the word "null" to be output to the user, just empty string. ...
1
vote
2answers
52 views

Finding the highest quarter of the year

I'm sitting here and do some practise but I just can't find the Solution. Maybe someone could give me some help? I have a table and should find the highest sale amount of a quarter per year. Data ...
1
vote
2answers
59 views

Checking if an Username is already in use

I am writing some scripts for my website, and I am currently focussing on checking if a username is already in use. I have tried writing a SELECT script where the datafield is selected and checks if ...
0
votes
1answer
47 views

Best relationship database design to manage types for different entities

Suppose we have to manage phone types for: Clients, Employees and Suppliers. Each of these can have multiple phone numbers, so for better management I would like to add phone type. Each entity can ...
0
votes
1answer
23 views

What is the “other miscellaneous information” in the Shared Global Area (oracle database)?

I'm studying Oracle database ,and it says here that the SGA contains these data structures : Database buffer cache Redo log buffer Shared pool Java pool Large pool (optional) Data dictionary cache ...
0
votes
1answer
35 views

How do I count and order by unique entries?

I have this: SELECT tblClient.[Printed Name], tblClient.[Address 1], tblClient.[Address 2], tblClient.City, tblClient.State, tblClient.Zip, tblClient.Phone, tblClient.[Email Address] FROM tblClient ...
2
votes
1answer
56 views

Listener pointing to incorrect AlwaysOn Availability Group

All, Thanks in advance I have two instances of SQL Server 2012 SP1 on a three node WSFC with a HAdr group on each instance with a corresponding listener. Instance 1's listener points to Instance 1, ...
1
vote
1answer
32 views

SQL Server: affect other transactions?

I'd be surprised if this existed, but will ask just in case. Is there some mechanism which would allow one transaction to affect another (outside) transaction? For example: BEGIN TRY BEGIN TRAN ...
0
votes
1answer
58 views

How to delete from two tables same field name in single query?

Help me, I want to delete same filed name from two tables in single query, I Attached query but it's not working... DELETE PersonalTrainerMasterData ,PersonalTrainerCheckboxData FROM ...
0
votes
0answers
10 views

Reporting Services Scripter ScheduleID Error

I'm currently in a SQL Server 2005 environment that's being upgraded to 2012. I need a tool to script out all of my SSRS subscriptions, and I chose to use RSScripter. I'm having an issue whenever I ...
12
votes
1answer
133 views

“Cannot create a row of size 8074 which is greater than the allowable maximum row size of 8060” while altering the table

I am trying to alter a column in a table. The existing table is like this: CREATE TABLE [dbo].[table]( [id1] [int] NOT NULL, [id2] [int] NOT NULL, [id3] [int] NOT NULL, [name] ...
0
votes
0answers
33 views

The best way to query a partitioned table in Oracle

I have a table in an Oracle database, partitioned by a field. In our application we need to query data that is scatered across 2 partitions. Can you please tell me which method is better: making ...
2
votes
1answer
65 views

SQL Server Replication questions

This is kind of the part 2 of Replicating a SQL SERVER database & Optimization that I started earlier this week, but I believe it owes to be a different questions now that I have a clear idea of ...
0
votes
0answers
25 views

Avoid using SOQL/DML query statements in trigger

SELECT field1 FROM sObject WHERE field = 'Myconst' LIMIT 50000; I need to replace this field = 'const' by storing this const in a variable which suppose is: String constVar = 'Myconst'; SELECT ...
2
votes
1answer
68 views

Using scope_identity() to get ID “during” insertion of row?

I have a column that has an ident_current constraint on it to populate another column, like so: alter table dbo.Employee add constraint dbo_Employee_D1 default ident_current('dbo.Employee') for ...
2
votes
2answers
34 views

PostgreSQL using count() to determine percentages (cast issues)

I'm trying to run the following query to provide the % of records in my patients table that have a value entered in the refinst field. I keep getting a result of 0. select (count (refinst) / (select ...
1
vote
1answer
56 views

What is a good/healthy mysql query execution time?

What is a good/healthy mysql query execution time? To my calculations: The site gets 1000 unique visitors per hr 10 page view for each unique visitor 5 minutes for each unique visitor ...
4
votes
3answers
114 views

Virtual Log Files (VLFs) Fragmentation

I have a database with 160 VLFs. How do I determine whether the VLFs are fragmented? Further, how do I find the percentage of fragmentation? Another thing that I want to confirm: Are the following ...
7
votes
5answers
508 views

Performance tuning a Great Circle distance calculation

I have a query that I am using to find locations that are within 1km of a known point. To do this, I am using the Spherical Law of Cosines formula with my latitude and longitudes. Currently, the ...