An acronym for "Structured Query Language", 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 access privileges.
1
vote
1answer
19 views
Postgres 9.2 select multiple specific rows in one query
I have a table with three columns,
Id Serial.
Value real.
timein Timestamp.
I want to select the values based on a range of days ie. from two days ago until now. The table may contain one or two ...
4
votes
1answer
49 views
How to get a row_number to have the behavior of dense_rank
I have a stored procedure will be used to page through data. One of the requirements of the procedure is to have a parameter that will be used to sort two columns of data, the sorting should be used ...
-1
votes
0answers
27 views
How can I delete duplications with one query? [closed]
Is there any way to delete duplications with one, or only two queries? I'm not good with SQL.
Now I'm trying this solution:
$le = mysql_query('SELECT * FROM tbl_answers');
while($i = ...
2
votes
1answer
31 views
How can I include more query in one query?
These are my tables:
tbl_answers =>
aid
qid
answer
uid
dateposted
emailnotify
namedisplay
status
isbestanswer
tbl_questions =>
qid
question
...
0
votes
1answer
19 views
Separate table by often changed / not often changed data?
I have a application which querys different gameservers, and stores for example if the server is online, and how many players are connected. But of course there is also data which is changed rarely.
...
0
votes
0answers
29 views
Simple SQL statement [migrated]
I've been over-thinking this too much. Let's say I have a table TEST(refnum VARCHAR(5))
|refnum|
--------
| 12345|
| 56873|
| 63423|
| 12345|
| 56873|
| 12345|
I ...
2
votes
2answers
23 views
MySQL many to many relation
Sorry is this seems a stupid question, but I have a table of server addresses and a second table with a list of hardware devices which use the addresses, it is possible for multiple devices to use the ...
3
votes
1answer
44 views
Convert SQL Server 2012 SSIS package to 2008
I've created a few SSIS packages in SQL Server 2012 that I need to run on SQL Server 2008. I've been told that it is impossible in their current state.
Is there a way to convert the 2012 packages to ...
3
votes
6answers
102 views
Backup very large table
I have to update certain values of a large table (for the sake of a presumed example, it is called 'Resource' and it is over 5M rows) and thus I have to make a backup before performing the changes. We ...
1
vote
6answers
47 views
Best practices with large amount of data
I'm building a solution and I have a question.
All my data is currently stored in a unique table. Each row of data is associated with a type.
My question is, what's the best practice for defining a ...
6
votes
2answers
69 views
Is there any way to trace optimizer's work in MySQL?
Just like the MEMO structure in SQL Server which is kind of a "paper trail" of steps the optimizer takes in optimizing the query. Is there anything in MySQL through which I can get the information ...
4
votes
2answers
69 views
Should I use a composite or single-column index?
I have the following columns in my database table (Medicines).
ID bigint,
MedicineName nvarchar(50),
BrandName nvarchar(50),
MedicineCode nvarchar(20),
and price,quantity.
I am making a stored ...
-1
votes
1answer
33 views
Adding a column at a specific position using DBMS_REDEFINITION
Can anybody tell me how I can add a column to table at a specific position using the DBMS_REDEFINITION package from Oracle?
0
votes
0answers
29 views
Match two large tables finding similar data [closed]
I have two tables in MySQL. Table 1 contains much data, but Table 2 contains huge data.
Here's the code I implement using Python
import MySQLdb
db = MySQLdb.connect(host = "localhost", user = ...
1
vote
1answer
23 views
Moving postgresql data directory
I moved postgresql's data directory by following the following steps:
Stop postgres
cp -a source_data_directory destination_data_directory
export PGDATA=destination_data_directory
Changing data ...
-5
votes
0answers
45 views
Query for Oracle database [closed]
I have a problem in writing a Database Query
Problem: I have the below fields in my table Fields: Primary_ID(PK) ,E_ID, Bank, REQUEST_STATUS, START_DATE, STATUS
Data: REQUEST_STATUS may contains ...
-4
votes
0answers
42 views
oracle database query [closed]
I have a problem in writing a Database Query
Problem: I have the below fields in my table Fields: Primary_ID(PK) ,E_ID, Bank, REQUEST_STATUS, START_DATE, STATUS
Data: REQUEST_STATUS may contains ...
1
vote
0answers
26 views
How to Change location of postgres cluster and database within the same machine? [duplicate]
I have my present database cluster of postgres at /mnt/my_hard_drive which I want to change to /home/myfolder. I also want to move all my databases present in the present cluster to /home/myfolder. Is ...
1
vote
1answer
23 views
Insert Row With Foreign Key Equal to ID - Circular Reference
In MySQL database I have an events table which has a circular reference to itself with the following columns.
id (PK) | user_id (FK) | event_id (FK) | title
Each new row inserted has a circular ...
0
votes
1answer
30 views
“relation does not exist” trying to import mysql dump into postgres
environment:
ubuntu 10.04
mysql server 5.1.69
postgres 9.2
Here's the sequence of steps:
created a new postgres database, myDatabase
executed this command: mysqldump -u root -p ...
0
votes
2answers
26 views
Query WHERE clause and JOIN
I'm having an issue using a WHERE clause and JOIN.
SELECT * FROM `CallDetailRecord`
WHERE `StartTime` >=1357102799000
AND `StartTime` <=1357880399000
JOIN `CallEvent` ON `EventID` = ...
0
votes
2answers
22 views
copy package from schema B to schema C
I am in the next situation: I am using oracle 11g. I am connected to an user, lets say schema1, where are a lot of permissions. I want to create a script which will copy the Package1 (and its body) ...
4
votes
1answer
414 views
CTE memory space
How do CTE memory space work? When you have complex SQL statements executing with the CTE and you get unusually large result set, can it increase the logical reads of the query?
I have a CTE that is ...
-1
votes
1answer
51 views
Single quote issue
I have to update a column where I am giving query which is
Update Table
Set col = '[189] IS NOT NULL and [189] <> '''
Where colid= 198
But it's giving output:- [189] IS NOT NULL and ...
0
votes
2answers
64 views
Use an Alias in Where Clause Subquery
I need to show some fields from another table in Oracle. Here is my query:
SELECT
ANGGARAN.SIMPEG_PEGAWAI.ID_PEGAWAI AS KODE,
ANGGARAN.SIMPEG_PEGAWAI.NAMA,
ANGGARAN.SIMPEG_PEGAWAI.NIP,
...
-1
votes
1answer
21 views
checking a folder whether required file is present at a regular interval [closed]
i have 4 folder hierarchy in a following format :
Hourly Daily Weekly Monthly.
In every folder i have files which is coming in a frequency based on their folder's name.
Now , i have ...
0
votes
2answers
56 views
Running a query within a scheduled job
I am looking at running the following query within a scheduled job weekly:
Select TOP 10
s.database_name,
m.physical_device_name,
CAST(DATEDIFF(second, ...
0
votes
1answer
31 views
String replace using concatenated strings from various columns
I'd like to remove a substring in a column via update statement. The substring to replace consists of multiple strings from other different columns but in strict order.
The specification says:
...
0
votes
4answers
31 views
Are all matching indexes (indices) searched for a query?
If I have multiple indexes that include a common attribute - will each index be searched upon a query involving this attribute? Or is only one index searched?
-1
votes
1answer
48 views
populate table header and data in another table column [closed]
I have 2 tables: Departments and Employees, where Department_Id is primary key in the departments table and a foreign key in Employees table.
Departments Table:
Department_Id Department_Name
10 ...
0
votes
2answers
19 views
Partitioning MySQL for “expired” transactions to improve performance
I am dealing with an existing application that uses the database as a sort of transaction log in several cases, for example orders or payments. These tables are large (20 - 60 million rows) and poorly ...
1
vote
1answer
36 views
Mysql: Schema/Query Performance Approach for aggregated mailbox folders
I am about to code a messaging system where users can write messages to other users. User can create custom inbox folders for sorting the messages they receive, however, every user has 2 main inboxes: ...
-2
votes
3answers
71 views
Left Join not giving desired result
I have two Datasets
FEES PAYMENTS
CrsCode InstNo FEE Regno CRSCODE Instno Payment
CA1 -2 100 R1 CA1 -2 100
CA1 -1 200 ...
-1
votes
0answers
28 views
Using If statements in stored procedure breaks it [migrated]
This is my stored procedure:
USE [Hires_new]
GO
/****** Object: StoredProcedure [dbo].[ps_selectNewHireWorkPeriodsSQL] Script Date: 05/14/2013 12:59:28 ******/
SET ANSI_NULLS ON
GO
SET ...
-1
votes
1answer
32 views
Directory lookup failed during log shipping
I have configured log shipping for all our SharePoint 2010 databases. All worked well since Friday and today Monday I ran this query:
SELECT *
FROM [msdb].[dbo].[sysjobhistory]
WHERE [message] like ...
0
votes
0answers
20 views
How to merge a select statement with a calculated value as new columns? [migrated]
In my sql server code, I have this select statement
select distinct
a.HireLastName,
a.HireFirstName,
a.HireID,
a.Position_ID,
a.BarNumber,
a.Archived,
...
0
votes
0answers
41 views
How to loop through a select statement? [migrated]
I have this select statement
declare @t table (Percentage float)
DECLARE @acc INT
SET @acc = 1
DECLARE @max INT
select @max = max(HireID) from NewHire
WHILE (@acc <= @max)
BEGIN
IF ...
2
votes
2answers
39 views
DB2 will not INSERT into Created Temp Table that I created
I normally use SQL Server but for this project I'm having to learn DB2. If I can get the below code to work I'm set for the whole project. Below is a elementary example of what I cannot get to work. ...
-1
votes
2answers
57 views
How to do division from select statements in sql server?
I am trying to create a select statement that can return a table of 1 column.
Basically, I am looping through all the records of NewHire, and then using its id, to select stuff from another table. I ...
2
votes
1answer
63 views
Reorganize full text catalog is offline or online?
I need to schedule a Full Text Search Maintenance and I was reading this link: http://msdn.microsoft.com/en-us/library/ms176095.aspx. Reading this documentation I am supposing that I need to ...
3
votes
3answers
98 views
Fixed length text file insert into SQL table
I am not a DBA on this one and I will not have access to BCP or anything like that. So I'm wondering if there is still a way to do it in SQL keeping it very basic.
I have 100's of text files that ...
-1
votes
1answer
61 views
Validate each parent intermediary is also a parent to itself
I have a table for which I want to validate where each parent intermediary is also a parent to itself. How to write query to validate this?
COLUMN DATATYPE DESCRIPTION
...
-1
votes
1answer
57 views
How to merge data from 2 databases [duplicate]
I have a SQL-Server database that crashed while I was away on vacation. All info from 5/2/13 is missing from our current database because my replacement implemented a back-up of the database from ...
3
votes
1answer
42 views
Scheduled stored procedure on all databases in my server
On SQL Server 2012 (not express edition) I'd like to schedule the execution of a stored procedure every hour.
On the same server I have lot of databases with the same structure, and I'm constantly ...
0
votes
0answers
21 views
developing procedure in sql for global use
what type of complex procedure can i develop in SQL which will make others work easy as well ,
like in Java , i had developed a program for FTP so that anyone can import this program and can use it ...
-1
votes
0answers
34 views
Abot SQL Server's Tabular [closed]
Goal:
The goal is to view if SQL server 2012 tabular and its in-memory ability with can be used in relation to PowerView, Excel and Reporting service at the same time. No different instance shall be ...
0
votes
1answer
25 views
PostgreSQL created a PostgreSQL user on mac. Is this necessary?
I just installed PostgreSQL on a Mac (Mountain Lion) today.
The installer created a mac user PostgreSQL on my machine. After installation, the user still exists.
My question is that why postgreSQL ...
0
votes
0answers
78 views
how to find similar word with more similarities
how to Find words with length less than or equal...
declare @inp nvarchar(max),@data nvarchar(max)
set @inp='You can dance, you can jive, having .... jove... jve, ...'
set @data = 'jeve'
...
4
votes
1answer
29 views
How to view the full, flattened query underlying a Postgresql view?
If I have a view on a view on a view (etc.), is there a way to show the full query that this expands/flattens to?
0
votes
1answer
22 views
createdb command error : could not connect to database
I am using the following command for creating database in postgresql.
createdb -D pg_default -E UTF8 -h localhost -p 5432 -U pramil -W pramil mydb
but this command results prompt for password.When ...
