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)

0
votes
1answer
33 views

where in (sub query) vs join

just want to ask about how to optimize my query. because i feel efficiency using join instead of "where in" sub query can someone enplane the deference SELECT C.Customer_id, C.tran_id, ...
0
votes
0answers
28 views

MySQL: How to get all values in “TICKER” column`? [migrated]

I never used SQL before, I want to get all values in "TICKER" from this database: The first statement select TDATE, price, return1 from STOCK_DATA where TDATE < 20131231 and TDATE > ...
0
votes
2answers
415 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 ...
0
votes
1answer
14 views

How can I Use Access to combine tables of information

I have two tables in access with a common ID number in both. One table has mail to info and the other table has account information. The account information can have multiple listings per ID. The mail ...
-1
votes
0answers
14 views

Template for MySQL database upgrade script

What is the equivalent of this Microsoft SQL Server upgrade script template for MySQL? I want to upgrade my database version in repeatable transactions in sequential scripts as I develop an ...
2
votes
1answer
177 views

How to allow connections to SQL Server with 2 differents ip

I have a small issue here: I have a SQL Server instance 2012 (let's call it INSTANCE) on a cluster. I also have 2 network interfaces for this instance: SQLINSTANCE.my.metwork ...
2
votes
1answer
577 views

SQL Server 2008 R2 cluster installation error

I was trying to install SQL Server Cluster (Launch wiard to install single node SQL Server 2008 R2 faliover cluster) .. The setup checks displayed no error and the installation started after all the ...
1
vote
2answers
2k views

Oracle query is slower the second time

I have a general question about something I'm seeing in performance tuning in Oracle. I have a query that I'm testing. It's too big and complex for me to provide a simple example, sorry! (I tried ...
3
votes
2answers
91 views

Slow fulltext search due to wildly innacurate row estimates

Fulltext queries against this database (storing RT tickets) seem to be taking a very long time to execute. The attachments table (containing the fulltext data) is about 15GB. The database schema is ...
1
vote
3answers
84 views

Clustered Index improvemens for particular queries

I found a table that looks like this: CREATE TABLE [dbo].Table1 ( id INT primary key IDENTITY (1, 1), [idUser] INT NOT NULL , [Amount] INT NOT NULL , [Attempts] INT NOT NULL , ...
3
votes
4answers
262 views

Keep track of time intensive stored procedure with prints

I am no database admin nor is my SQL-foo any good (yet), but have a few tasks to get done in MSSQL, and one is a rather time intensive procedure where I fetch from a CURSOR and WHILE @@FETCH_STATUS = ...
1
vote
1answer
116 views

Sql Server sys.Traces log

Working with traces on production server I found some mysterious entries to me in sys.Traces, When I run below query it shows me status of all traces as ‘Paused’ along with entries in ...
0
votes
1answer
126 views

Query multiple rooms with different conditionals (Adults, Children)

I have a simple query where I select available x Rooms with x Adults + x Children per hotel that matches a date range, but I'm having a hard time trying to figure out how to query a list of rooms per ...
0
votes
0answers
36 views

Should I create a Factless Fact Table or Denormalise my table

I am creating a data warehouse from a store database and I have a question regarding the design of my dimensions and facts. In the store database a table exists for Person, Person_Address and ...
0
votes
0answers
40 views

Thoughts on further optimizations

So I have this application. It runs on a server. There is a portion of the code that is taking around 10-15 seconds to run, it contains some queries, logic, as well as some code to update the ...
0
votes
1answer
21 views

Set method to change StartMode property using SqlServer.Management.Smo.Wmi.Service

I'm trying to change SQL server Configuration manager settings using Microsoft.SqlServer.Management.Smo.Wmi.Service. Microsoft provided with a list of methods & properties here. I used the ...
0
votes
3answers
67 views

Get latest status of an item in the database

I have this table: ID|Item-FK |timestamp|status ============================= 1 | 123 | ... | OK 2 | 123 | ... | FAILED ... I want to query get all items which last status was FAILED. ...
1
vote
1answer
27 views

MAX (id) function with MySQli

How can I use the following statement to return only the record with the maximum PersonID from the table? /* Create the prepared statement */ if ($stmt = $mysqli->prepare("SELECT Max(PersonID) AS ...
0
votes
1answer
54 views

how to select first 9 numbers from other table from database using sql query?

I want to fetch first 9 numbers from matching with other column please help me to find out thank you....? SELECT MAINFILE.facno,GLMAST.fglhead FROM MAINFILE INNER JOIN GLMAST ON ...
0
votes
1answer
86 views

Text Storage and Database Design Optimization in a SQL Server Database

Given a database with a number of columns (c), where some of these columns contain text that is one of multiple values due to a set CONSTRAINT on the columns, what is the most efficient way to ...
0
votes
0answers
45 views

SQL Server : error 15208 Level 16, State 1, Line 1

Trying to Backup a certificate from SQL Server causes this error: Msg 15208, Level 16, State 1, Line 1 The certificate, asymmetric key, or private key file does not exist or has invalid format. ...
2
votes
1answer
55 views

How to get all logged in users to SQL Server database for this week?

I'm using SQL Server 2008R2 and I setup a testing database that I need to know who tried logging in so far. Is there a stored procedure or a View or anything that I can gather these type of ...
1
vote
1answer
87 views

Query does not use index (according to EXPLAIN SELECT)

Can anyone give me an indication, why this query does not use the Key on the table 'gtg'): ...
1
vote
1answer
90 views

How can I design this database?

So I have a ton of transaction logs in pipe-separated format spread across a few dozen files. Concatenated into one file, it's around 2.4 million lines. Each transaction has a store number and a ...
0
votes
1answer
24 views

MySQL Loop Through Each Row

I have two tables, division & template, in a MySQL database. division - DivisionID - DivisionName template - TemplateID - TemplateName Here is an example of my current data ...
3
votes
1answer
88 views

How can I prevent having inconsistent data under isolation level serializable in Oracle SQL?

I have the following table: InStores +--------+---------+-----+ | ProdID | StoreID | qty | +--------+---------+-----+ | p1 | s1 | 25 | | p1 | s2 | 70 | +--------+---------+-----+ ...
0
votes
3answers
341 views

Mysql - How to Optimize Retrieval Time in a Table

I have query like this! which has 200 million Records in a single table.. I am using BTree Indexes in my table... mysql> select COUNT(DISTINCT id) from [tablename] where [columname] >=3; ...
1
vote
2answers
87 views

SQL Backup tuning large databases

I am tuning SQL backups using compression, writing to multiple files, and changing the BufferCount and MaxTransferSize options. I have SQL instance with a 4 TB database and several smaller databases ...
0
votes
1answer
21 views

Drop/Create database and create schemas all in the same script at PostgreSQL it's possible?

I'm working on a project where all the time I need to repeat this tasks: Drop database sis_db Create database sis_db Create database schemas by running a custom SQL file which contains this code: ...
20
votes
6answers
13k views

How do I efficiently get “the most recent corresponding row”?

I have a query pattern that must be very common, but I don't know how to write an efficient query for it. I want to look up the rows of a table that correspond to "the most recent date not after" the ...
1
vote
1answer
33 views

Select statement for selecting every week's log record

Here is a simplified version of the table in question: +------------------------------------------------------+ | DatabaseName | LogRecordNumber | LogTimestamp | ...
2
votes
5answers
908 views

SQl Server Password Change after installation

I have installed SQL Server 2005, but at the time of installation I forgot to change my password. Now I can access my database only in window authentication mode, and I want to access the database in ...
1
vote
2answers
67 views

Are there any special characters that are never allowed in SQL?

I am a Java programmer. We always make database-related things configurable so that they can be easily modified by the DB team as per their requirements. I want to make some queries as configurable, ...
0
votes
0answers
26 views

Paging via Number of Result Record vs COUNT(*)

I have been working on fixing a piece of code for a customer that has been very slow for them. I have made that fix, and thats all lovely, but I noticed something odd in the paging. When the query ...
4
votes
2answers
114 views

How to store immutable, unique, ordered, lists?

I have an entity with millions of instances. Each instance has to reference an ordered list of items. The lists have to be unique so no list will be stored more than once. But once created, both lists ...
0
votes
1answer
46 views

Store the resulting list of a SELECT in a variable to count AND use the result

I have stored procedure that uses a cursor and for every fetch a duplicate SELECT, once to determine the number of IDs found (SELECT COUNT(ID) FROM TableA WHERE something.. @cur_var) and if the ...
1
vote
1answer
49 views

Case with multiple conditions

I need to change returned value, from select statement, based on several conditions. I tried something like that: ,CASE i.DocValue WHEN 'F2' AND c.CondCode IN ('ZPR0','ZT10','Z305') THEN c.CondVal ...
1
vote
1answer
130 views

Profiling parameters

I was trying to fine the parameters of a query I suspect to be causing unnecessary logical read and eventually captured it in profiler, however parameters @p3 and @p4 are not listed. Is anyone able ...
1
vote
1answer
41 views

SQLAnywhere: Visualize in real time CPU and RAM consumption of sql connections

I want to keep track of which connection use most of resources. Within Sybase Central (SQL Anywhere 9, 12), for each server and database, we have pane to check in real time All Connected Users and ...
0
votes
2answers
169 views

mysql need help optimizing query

I have a table containing servers logs, and another table containing rules to match certain and drop them. The logs tables contains around 1 million rows, and there are about 20-30 rules. The ...
2
votes
4answers
106 views

Trigger or Stored Procedure?

Let's say I have two tables, foo and bar: CREATE TABLE foo( foo_id serial NOT NULL, count integer NULL, PRIMARY KEY(foo_id) ); CREATE TABLE bar( bar_id serial NOT ...
1
vote
1answer
57 views

SQL Azure Performance of new servers

I have a fairly small database ~200MB which when running in the web edition of SQL azure is lightning fast. I've switched it to the basic edition and all of a sudden a group of queries which took less ...
0
votes
1answer
38 views

Stored proc getting ANSI_NULLS and ANSI_WARNINGS error when executed by application

I have a stored procedure that is getting the following error when executed via an application : Heterogeneous queries require the ANSI_NULLS and ANSI_WARNINGS options to be set for the ...
3
votes
2answers
86 views

Why postgres is using an odd index with no relation to the query

(Debian 7, Postgres 9.3, dedicated machine with huge cache) I have one big table called process_data (14gb) and another tiny lookup table called process_location. I'm doing a query between these two ...
0
votes
2answers
91 views

SQL Server 2012: Full Text Catalog taking up all the disk space

We have created full text catalog and index for a pretty large table. The column on which the index is being created has a datatype of varchar(max). The problem started as soon as we started ...
0
votes
1answer
24 views

Design: Fitting variable hierarchy of text files into a relational db

I have a large data corpus (several TB) made up of data gathered through customer support queries. I've been asked to set up a database to make this data more accessible, but as I'm kind of new to ...
1
vote
2answers
96 views

How to deal with very large transaction logs in SQL Server [duplicate]

Here is my situation: I have being asked to deal with a SQL Server 2008 R2 database that has a transaction log that is several times bigger than the database itself. The database is in full recovery ...
1
vote
1answer
41 views

Getting Time Duration

I have a table like below: I want to get time duration for each record which SPEED is greater than 100. I written a function for that, it’s working fine , but my problem was i have millions of ...
1
vote
1answer
19 views

Adding a “position” number in Mysql

I got the following query and result currently: mysql> SELECT songname,COUNT(*) as count FROM etrstats WHERE songname != '' AND `when` >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) GROUP BY ...
4
votes
2answers
3k views

What are some common and useful fields for a users table in a database?

I want to begin implementing user functionality on my website, but I'm not sure exactly what kind of information I should be storing. Obviously the basic things like username, password, password hash, ...