1
vote
1answer
3k views

How do I perform a UNION query on a dynamic list of tables?

My database has an unknown amount of tables, named with the same prefix followed by a random string: _ct_<random_string>. Each of these tables has the same data structure. I also have another ...
5
votes
1answer
2k views

SQL Server ODBC Mirror/Failover Partner

Background/Context We are in the process of moving our SQL Server 2000 databases to a mirrored SQL Server 2008 R2 server with a witness and automatic failover. We have both .Net and Access ...
12
votes
4answers
2k views

Reason to not use nullable number in Oracle?

Our company is interfacing with another software company for a joint project, and we were told that, if a particular value should not be displayed, we should pass in a -5000 (their arbitrary sentinel ...
3
votes
2answers
3k views

How to connect once for all queries in SQL Server Management Studio?

SSMS asks me to connect for every query in my project. Is there a way to connect only once per connection for all of the queries using it in my project? The answers below (March 2014) don't answer ...
1
vote
0answers
613 views

Timeout on remote query over database link

We are trying to verify if a database link is up before inserting data into a remote database. We have no control over the remote database's behavior and status. We need to set a timeout on a query ...
8
votes
2answers
2k views

Why you want to avoid Dynamic SQL in stored procedure?

I have heard one said you do not want to use Dynamic SQL. Can you give some concrete example or real-life example? Personally, I code it a few times in my database. I think it is OK because it's ...
5
votes
2answers
818 views

Connecting to a Remote SQL Server 2008 Instance

I work with SQL Server 2008 at my current job and the way I connect to the (backup) server where The SQL Server 2008 instance is installed is by doing a remote desktop from my local work machine into ...
3
votes
2answers
7k views

MySQL: Loop over cursor results ends ahead of schedule

I'm executing a loop that iterates over a cursor's results. The code is inside a trigger function, and the part that matters looks like that: EDIT: Sorry, stupid mistake. The trigger is executed ...
4
votes
1answer
1k views

How do I merge two XML variables in SQL Server (2005/2008)?

Forward: I've already read this StackOverflow thread and it does not address the depth retention I need. I want to create an XML document that contains the data definition objects for a single ...
6
votes
2answers
2k views

How can I save a severely fragmented database/table?

I've recently made a discovery that might explain my slow SQL run times. I found out that the default in SSMS is to allow mdf growth of 1MB at a time. When the size of one table alone is roughly 23 ...
3
votes
2answers
422 views

Bug in PL/pgSQL function creation

I don't know if this question better suits here or in SO ... This is a script that I'd like to launch (the code of the function was copied from a question on SO): \c mydb create or replace function ...
3
votes
2answers
2k views

Oracle: deleting data from tables leads to data file fragmentation?

When randomly deleting ~5GB from a ~10GB Oracle table, I suspect that disk space is left in fragments. Is there a way to know about the disk state and any query to defragment or shrink the space?
4
votes
3answers
1k views

What should I consider when deciding between passing a comma-delimited string to a stored procedure instead of calling it individually per record?

I have to run the same stored procedure for a lot of records (hundreds or thousands, depending on user selection). The procedure is fairly basic: insert a record in two separate tables with some ...
1
vote
1answer
118 views

Check ruby gem and SQLite3 for FTS3 or FTS4 support

I have installed SQLite3 on Mountain Lion via MacPorts and Ruby along with sqlite3 gem using RVM. I'd like to know if there's any way for me to understand if my SQLite3 installation supports FTS4. ...
6
votes
1answer
218 views

Selecting 'edge' records in a sequence of data

I have a table of items which run sequentially by date with both a start and end for each entry: ID | Start | End ---------------------------------------- 1 | 2012-08-20 00:00 | ...
4
votes
1answer
739 views

How can I manage Primary Key length limit of 900 bytes when using hirarchyid 2 columns?

I have to define a Primary key on a table which has following 4 columns and its data types. GSiteID hirarchyid,, SiteID varchar(10), GComID hirarchyid, ComID nvarchar(10) As we know there is limit ...
6
votes
3answers
7k views

How database size affects performance: Theory vs reality

There is a lot out there that says database size should not affect performance to any great degree. As long as indexes on tables fit in memory the database should remain performant. However what is ...
4
votes
1answer
367 views

Improve query performance with index

I am looking to create an index for a database to acheive better performance. I am using this query: SELECT DISTINCT t1.* FROM current_order AS t1 LEFT JOIN receipt AS t2 USING ...
2
votes
2answers
4k views

Oracle.exe (SHAD) process keeps increasing

I have an Oracle Server 11g that we use for integration tests. For some reason, the processes count [select count(*) from v$process;] keeps increasing up to the limit, causing ORA-12514: TNS:listener ...
1
vote
2answers
806 views

Single or multiple databases?

I am in the progress of designing a database (or databases) for somebody and since I am a beginner I would love some advice. The data is described as: Customer1 (c1.type1, c1.type2, c1.type3) ...
6
votes
4answers
4k views

SQL Cluster without a shared disk. Possible?

Is it possible to create a two node cluster using two basic network servers that only have local disks? One will act as an idle standby server. Without knowing too much about clustering I'm not ...
2
votes
1answer
385 views

Default Constraints with Merge Replication

I am using merge replication in SQL 2012. Why can't you mark default constraints as NOT FOR REPLICATION? You can disable all default constraints for a merge article, but it is all or nothing so it ...
1
vote
0answers
1k views

Sqlsrv sqlsrv_num_rows FALSE, adding cursor type times out [closed]

$sql = "SELECT * FROM lastdeath"; $result = sqlsrv_query( $con, $sql); if( $result === false ) { die( print_r( sqlsrv_errors(), true)); } $row_count = sqlsrv_num_rows($result); echo $row_count; ...
5
votes
1answer
894 views

Can NOLOCK in a stored procedure be overridden when executing it?

Our application interfaces with a partner's application by calling one of their stored procedures. They insist on sprinkling NOLOCK hints throughout their code and this is a long stored procedure. ...
5
votes
3answers
939 views

Learning DB2 without a local install

I will be starting a new job in about 5 weeks, and want to spend some private time really getting to grips with as many of DB2s features as possible, as it is the DB used in the new company. Am I ...
3
votes
1answer
844 views

Microsoft SQL Server 2008 - Catching user role changes with SQL Server Profiler?

I'm trying to figure out why one of my SQL server users keeps losing sysadmin role when I uninstall a particular program. Can I use the SQL Server Profiler to track down the action that causes this to ...
5
votes
4answers
1k views

optimizing a compare query

Suppose I have two tables, A and B, and I know that size(A) = size(B). I want to confirm that the data in both tables is the same in three given columns, suppose they are X, Y, and Z (there are no ...
6
votes
1answer
24k views

Why Oracle sessions are still alive after two weeks being Inactive

DB: Oracle 10g O/S: Windows Server 2003 64 bits I query list of Oracle sessions generated by web applications (filter by program=w3wp.exe) select * from V$session where UPPER(program) LIKE '%W3%' ...
0
votes
2answers
5k views

What program should I use to open .db3 files?

I have a series of .db3 files in my computer. They are like filename1.db3, filename2.db3, filename3.db3, filename4.db3 and so on. I can open filename1.db3 with sqlite editor. But when I open ...
2
votes
1answer
356 views

Are JOINs on non-indexed columns faster than sub-queries?

I know JOIN on indexed columns are faster than sub-queries in a query result. I am confused if : JOINs on non-indexed columns are also faster than sub-queries or not.
1
vote
2answers
415 views

MySQL standalone

I have installed MySQL 5.5.27 on my MAC using the binary installer. I am able to run the mysql server with /Library/StartupItems/MySQLCOM/MySQLCOM start. But I am not able to run the mysqld with ...
3
votes
3answers
157 views

How to restrict sequence like ID type to C type like int64_t, uint64_t, int32_t?

In C99 I can be pretty clear about the size/domain of an integer type. When interfacing a SQL database like Oracle or Postgresql from a C program I want to create a table with integer types that ...
0
votes
1answer
471 views

Providing an ad-hoc report facility for business using in MySQL and PHP?

We are using MySQL 5.2 CE. We need to provide the business users a way to create their own ad-hoc report. Could you give a suggestion and an example, if this can de done using PHP?
7
votes
2answers
5k views

Designing a user authenication (Roles & Rights) module

I am trying to model a User Authentication module for a MS SQL Server database that will be the back end to a Delphi UI Application. Basically, I want to have user accounts where the user belongs to ...
2
votes
4answers
877 views

Limiting Generated Sequence Values in Multi-table Insert

In Oracle, given the following objects: create table a (x number ); create table b (val number ); create table c (val number ); create sequence my_seq; Suppose I populate table a as follows: ...
5
votes
4answers
256 views

Why is Clustered Index on Primary Key compulsory?

Why Primary Key constraint creates Clustered Index on the PK column by default? Can we create a table which has a primary key, but NO clustered index. I need PK constraint to maintain the unique ...
9
votes
3answers
7k views

Can I connect to a SQL Server 2000 instance from SQL Server Management Studio 2012?

I would like to update my development machine to SQL Server 2012 but I still manage some (very old) SQL Server 2000 machines. Wil my 2012 SSMS be able to connect to those SQL Server 2000 machines? ...
3
votes
2answers
5k views

MySQL Workbench copies Schema, but not data, from SQL Server 2008

I need to copy/migrate a database from MSSQL (SQL Server 2008) into MySQL. I am using the MySQL Workbench kit, and work through the process of the Migration. Each respective DB user has full access, ...
2
votes
1answer
890 views

impdp import fails with object already exists in oracle 10g?

I exported the dump using EXPDP command. After exporting I dropped the user and the associated tablespaces by logging is as / AS SYSDBA. Then I re-created the User and the Tablespaces. Then I ...
3
votes
1answer
115 views

MySQL - Partially restore binary log

I have restored a dump into MySQL. I also have a binary log, which I want to partially restore, let's say from position 10 - 2500. How can I do that?
5
votes
2answers
17k views

SQL Server 2008: The login is from an untrusted domain and cannot be used with Windows authentication

The question here is different from 1 & 2 When trying to connect to a SQL Server database that is on another system in the network both are in workgroup, when attempting to connect to a SQL ...
8
votes
2answers
303 views

What is the function of rebuilding indexes?

I'm young in the IT world, and I'm learning daily. I just started working with SQL databases, and I have lots of basic questions. One in particular, What is the function of rebuilding indexes? I have ...
1
vote
1answer
227 views

Data storage in innodb

I am new to mysql administration and I came to know about the data storage in myisam is through .frm, .myd and .myi. I could not find the data storage mechanism in InnoDB rather than its storage in ...
5
votes
2answers
294 views

What are sensible/rational character limits in a database e.g. for a persons name

This is a general question about database admin. Is there some kind of standardization for character limits on fields in a DB? It makes sense to specify character limits on the database end for ...
2
votes
1answer
166 views

Problems on filegroup size — SQL Server 2005

consider FG_january_2011 file group contains 100000 records. and FG_january_2012 file group contains 2000 records. update Table_Name set date=dateadd(yyyy,+1,date) where Year(date)=2011 if i execute ...
4
votes
1answer
11k views

Show procedure code in MySQL

I've tried to show the SQL code of a stored procedure called add_pixel: mysql> SHOW PROCEDURE CODE add_pixel; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that ...
0
votes
1answer
723 views

mysql “Unsafe statement”

I get a lot of following messages Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it accesses a non-transactional table ...
5
votes
1answer
6k views

Mongodb - Returning the points nearest to a location, with distance

What is the MongoDB's equivalent to this query: SELECT 111151.29341326 * SQRT( pow(-6.186753-`Latitude`, 2) + pow(106.772835-`Longitude`, 2) ...
1
vote
2answers
160 views

How do I create a rule for a Primary Key

I am using SQL Server 2005 and I need to create a primary key with an alpha character and 3 numbers together: p001 b201 I know I need to create a rule and bind that rule to the primary ...
4
votes
1answer
781 views

How to selectively replicate a PostgreSQL database

I would like to keep two PostgreSQL databases with the same schema, but have one replicated from a master that only keeps a small portion of the live data. Basically the master takes in live data ...

15 30 50 per page