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
55 views

SQL - Referential integrity

seems like my problem pretty much describes GC (Garbage Collector) but I don't want to make a procedure to run every X time. so this is my question: I have three tables or more, refer to those as ...
2
votes
2answers
185 views

Oracle upgrade, v$version what is it actually doing?

There are 42 threads tagged as oracle8i, none of them answer my question... This is Oracle 8i (8.1.5.0.0) SQL> select * from v$version; BANNER ...
0
votes
0answers
27 views

How to store UserName who is Updating the value of a table in For Update Trigger?

In my web application, am creating a log process. I have created an update trigger, its working perfectly but I need to know who updated this data i.e the user who performed this action. How to store ...
2
votes
1answer
84 views

Update old database with SQL dump

I had to recover a database with a some months old full backup. I have however in my possession a most recent but unfortunately incomplete SQL dump for this same database done with mysqldump. Is ...
2
votes
2answers
468 views

T-SQL - How to filter data from table

I'm new in DB world, so if you can help me it would be great. My problem: I have filtered some data and got a table with data, but need to filter them again. Picture might help you. For me, it is ...
1
vote
2answers
823 views

Delete rows from a large table with joins and aggregating (resulting in 1 % less rows in the big table)

I got a bit stuck on performance, so I thought about asking a bit of help. I have a working query, but unfortunatelly it feels rather slow and I know it's not as performant as it could be made ...
1
vote
1answer
231 views

Why DBCC CHECKDB is multiple times in error log

I have an issue with dbcc checkdb command . In the errorlog file I find the dbcc checkdb command multiple time within the interval of 30-45 minutes. I have scheduled a job which grep keyword error ...
0
votes
2answers
195 views

Which is better? A join or a SELECT IN? [closed]

I have a set of ids that I extract using a join of 2 tables. Now I need some information from 2 other tables. What would normally be the best approach? So a SELECT IN using the set of ids I already ...
2
votes
2answers
9k views

Oracle password has expired, however I have no way of changing it

When I connect to my local development database, I get an error saying the password has expired. I've been trying to change it with sqlplus to no avail: C:\>sqlplus ...
0
votes
0answers
48 views

sql server 2000 linked server works locally but not from remote machine

sql server 2000 linked server works locally but not from remote machine ,i am not able to use linked server remotely (from my desktop). i enabled TCP/IP for the sql Server and i enabled win&sql ...
0
votes
0answers
53 views

Is there a syntax to access the table name in the select query?

In MYSQL. I want to select the records which has the same contents with the table name. for example, consider the following table. <TABLE : tbl_1> +-------+------+ | id | no | ...
1
vote
1answer
104 views

.NET error when trying to create snapshot for transactional Replication

I encountered a bizarre prob today while creating a transactional publication on a SQL 2012 server running on Windows Server 2008R2. I had just had some success creating and initializing some Merge ...
2
votes
2answers
190 views

What can be done to further enhance performance of Multiple Join and Aggregate Queries?

I have a typical star schema simulated here, and I am mentioning two queries: first query simply joins the fact table with 2 dimension tables and 1 calendar table, and the second query joins and ...
2
votes
1answer
48 views

Order results from query to have a certain result at the top

I'm not sure there is even a way to do this, but thought I would ask anyway. I have the following example output from a query: Name Country Number -------------------------- Harry Germany ...
0
votes
1answer
323 views

Query: select all rooms which are not booked

I have a simple room booking system consisting of following tables: booking | id | user | begin | end | room | id | name | booking_map | id | room_id | I can list all rooms that are booked at ...
0
votes
1answer
74 views

Insert a group of consistent item with foreign key but colliding with existing items

Is there a way to insert a group of items that are dependent but consistent between them with unique primary keys and foreign keys but that are colliding with items in database. For example, given a ...
0
votes
1answer
460 views

MySQL select query result set changes based on column order

I have a drupal 7 site using the Views module to back-end site content search results. The same query with the same dataset returns different results from MySQL 5.5.28 to MySQL 5.6.14. The results ...
0
votes
2answers
91 views

Databases: are there universal datatypes?

While designing database tables (using some tool like Enterprise Architect), how do I use only 'universal' datatypes that will work with all databases when I need to switch to a different database in ...
-1
votes
1answer
38 views

Relation that combines entries with their subsequent entries, in order of date

I need to come up with a query that can do the following: I have a table with a bunch of transaction records, whose attributes are not important, other than the attribute Date. I need to come up ...
0
votes
3answers
221 views

Handling case-insensitive queries with case-sensitive data

What are some practices for designing a table, or queries, when it comes to case-sensitive data and case-insensitive queries? For example, I have a Products table that holds household goods, and ...
4
votes
1answer
65 views

Query uses Primary Key Index instead of Nonclustered index defined

I have this simple query and I am confused why the index is not working. SELECT lop.RecordID ProspectusID, c.c_code CourseCode, c.c_desc CourseDescription, COALESCE(c.c_major, '') ...
1
vote
2answers
363 views

Cannot add an account [non domain account ] to SQL Server 2012

Background: I have a application pool [ABCDEMO] in IIS. The identity of the appool is "NetworkService". I am trying to add IIS APPPOOL\ABCDEMO to my SQL SERVER 2012 on a Windows SERVER 2012. When I ...
1
vote
4answers
221 views

Which of these queries is best for performance?

Which of these queries are best for performance ? Sometimes I wonder if SHORT scripts really is the best thing to focus on. These scripts performs the same task. With left joins i can achieve what i ...
0
votes
1answer
148 views

Party Relationship Model in Practice - Insertions

I'm moving this question for StackOverflow in hopes to get perspective from a more database-oriented community. Here is a basic representation of what I'm doing (in pseudo sql): Parties - ID, ...
0
votes
0answers
57 views

All databases restoring in Suspect Mode in SQL Server 2012

I've just re-installed SQL Server 2012 (removed the evaluation copy and installed a licenced version) and now every database I try to restore, it fails to completely restore and the database sits in ...
0
votes
1answer
285 views

Setting Audit Events in SQL Server 2012

We have to do information assurance remediation on our SQL Server 2012 and came across the following finding: Check to see that all required events are being audited. So I ran these queries: select ...
1
vote
1answer
922 views

Order by alphabet and then by numbers

I have records like A5 A4 Z1 B2 C7 C1A C11A B1 B4 I want them to be sorted in this manner A4 A5 B1 B2 B4 C1 C11A C7 Z1 using the ORDER BY clause. I want them to be sorted by alphabets ...
1
vote
0answers
77 views

MySQL: What criteria should I base my table column order/arrangement/grouping on?

Does the order, arrangement or grouping of columns with large (such as long text descriptions) and small (such as bit and tinyint) field types have any noticeable impact on MySQL (InnoDB engine) ...
0
votes
1answer
192 views

Not exists/Where NOT in

Doing a pie chart in crystal. Items are Inquiries Referrals Followups A referral has to have an inquiry, A followup has to have a referral. I want to show pie chart of referrals to ...
0
votes
0answers
59 views

SQL Server JOIN with COUNT [closed]

I have two tables I'm trying to query across. One contains an entry for every time a user tunes to a particular channel in our middleware. The second is normalized table containing station ...
1
vote
2answers
2k views

mysql: using comma-separated values

I have a simple mysql table which I use as a server booking system. A user can log in to a server, if he has a valid booking for that server. A sample data might look like this: ...
1
vote
3answers
1k views

How to get a list/result of best selling items

I'm trying to get the results of my best selling products using SQL. My table is order_items which has the following columns. id|product_id|qty As there is a QTY field I have to somehow count or ...
17
votes
2answers
1k views

Index not making execution faster, and in some cases is slowing down the query. Why is it so?

I was experimenting with indexes to speed up things, but in case of a join, the index is not improving the query execution time and in some cases it is slowing things down. The query to create test ...
2
votes
0answers
483 views

Query optimization on a large table in PostgreSQL

I am not super experienced with databases, just have a college level course under my belt. I am trying to see if an existing query can be optimized. Currently on average takes over 300ms. There is a ...
0
votes
0answers
123 views

My queries are slow under load

I am performing a load test for my application. All my SQL queries which are fired from my application, individually look better and perform fast. The same SQL are becoming bottleneck when they are ...
3
votes
1answer
73 views

Restoring with replace going incredibly quickly [duplicate]

So I have a database (on a SQL Server 2008 R2 SP2 instance) that is 2TB uncompressed, with a .bak file that is 500GB compressed. As I have been toying with the fastest way to restore this database ...
4
votes
1answer
4k views

Syntax of INNER JOIN nested inside OUTER JOIN vs. query results

TLDR; If you look at the 2 execution plans, is there an easy answer to which is better? I purposefully did NOT create indexes so it's easier to see what's happening. Following up on my previous ...
1
vote
1answer
91 views

creating 2 database at the same time in db2

Do you know whether it is safe to have in one shell user db2inst1 creating a database A and having another shell the same user creating at the same time database B? create database A # shell 1 ...
2
votes
1answer
669 views

Return ResultSet with column names from postgresql Stored procedures

I have the following postgresql Function: CREATE OR REPLACE FUNCTION readMessage(messageFor INT, qid INT = NULL, ctxt INT = NULL, messageFrom INT = NULL, byTimeStamp BOOLEAN = FALSE) RETURNS SETOF ...
1
vote
2answers
71 views

SQL Server 2000 optimzation job hasn't run for a while

Our SQL Server 2000 used to run a Sunday morning 3am job of optimizing the database. Somehow it was turned off and hasn't run in a year. We have noticed slow access to the database. We turned it ...
0
votes
1answer
499 views

Calculating time spent on query cache lock

How can I calculate the total time my MySQL database is spending Waiting for query cache lock ? I've found two specific very simple tables that adding a SQL_NO_CACHE drastically improved the ...
1
vote
2answers
1k views

Protect SQL Server from hackers

Today, my SQL Server 2008 is attacked by hacker from IP address in China [4300 Login failure in last 7 hours]. I contacted GoDaddy support and below is what they told me. EXEC sp_readerrorlog 0, 1, ...
4
votes
1answer
177 views

Minimal Logging Conditions in SQL

I have written a script to test out the claims made on this page http://technet.microsoft.com/en-us/library/dd425070(v=sql.100).aspx in the table titled Summarizing Minimal Logging Conditions about ...
1
vote
3answers
353 views

How to determine if SQL Server will not execute parts of the script in parallel?

Are there any general rules or maybe easy way to tell if SQL script will execute in batches instead of "all at once"? USE UserDB; GO DBCC SHRINKFILE (DataFile1, 5); GO DBCC SHRINKFILE (DataFile2, ...
0
votes
0answers
58 views

Compare elapsed time for 2 oracle Sql files. (2300 pairs of sql files)

Version ORA 11G I have some timing comparisons that I want to do on about 2300 Pairs of Oracle SQL statements. I'm trying to convince management that tuning of these 2300 would give them a ...
3
votes
1answer
888 views

Can column name be “Group” in Postgresql or in any databases

I was designing a project which specifies that in a table what column name should be and one of the column name in the specification is "group". I tried creating it but it always throw a syntax ...
2
votes
3answers
388 views

Sql server - Rebuilding Indexes - Does it affect foreign keys?

i am looking at speeding up the performance of my database, and thought that Rebuilding some indexes might help. My question is, will this invalidate Foreign Keys from other tables pointing to the ...
1
vote
1answer
164 views

Easier way to change every user in every database to default schema = dbo?

There was recently a domain migration where our SQL Server is hosted. I have two servers and about 30 DBs on each. Every user was changed to the new domain but in doing so, their default schema ...
0
votes
1answer
603 views

Find nearest values from MySQL Table

I want to fetch nearest rates for a given value from below table. mysql> select * from rates; +------+----------+----------+ | ID | Type | Rate | +------+---------------------+ | 1 | ...
1
vote
1answer
224 views

Using coalesce on an index column

Does doing a COALESCE on an indexed columns in a WHERE clause e.g. WHERE COALESCE(table1.indexed_column, '9999-01-01') > table2.other_date_column affect indexing in a bad way? I think that it ...