sql

Are MySQL Foreign Key auto-generated names deterministic?

When constraints are created they are given names that look something like this 'FK5E6B788655A1514E'. I'm wondering if the name generation is deterministic or random. I noticed that two separate databases I was using, same schemas, ended up with the same FK names. Does it make sense when writing an upgrade script from one version of a ...

typed XML column with DateTime element - DateTime gets converted

I have a typed XML column in which I store the serialization from a C# object with a DateTime property. That DateTime is of Local type when I store it in the DB - although the serialized XML shows the time with an offset to GT time, as in '2009-09-22T13:52:32.2346252-07:00' (I live in Oregon). When I read the table (from within the SQL ...

READ COMMITTED database isolation level in oracle

Hi there, I'm working on a web app connected to oracle. We have a table in oracle with a column "activated". Only one row can have this column set to 1 at any one time. To enforce this, we have been using SERIALIZED isolation level in Java, however we are running into the "cannot serialize transaction" error, and cannot work out why. ...

Django generates 'WHERE ... BETWEEN ...' sentences ?

Actually, somewhere in the view: dif = datetime.timedelta(days=1) today = datetime.date.today() yesterday = today - dif ex = Fact.objects.filter(fecha_fact__lte=today ,fecha_fact__gte=yesterday ) It results to this SQL Query: SELECT `facts_fact`.`id` ... FROM `facts_fact` WHERE (`facts_fact`.`fecha_fact` >= 2009-09-21 AND `facts_fac...

SQL Select Entire Row by Distinct Columns

Hello, I need an sql statement which will allow me to select an entire row from oracle database, but by distinct columns. Here is a simplified database: Project_Num Title Category 0 Project 1 Admin 0 Project 1 Development 1 Project 2 Admin 2 Pro...

Oracle PLS-00103 error. How do you check for an existing record and do update or insert based on that condition?

I need to check if a record exists in the table or not from a SELECT statement. If the record exists, do an update otherwise create a record on the table. I'm trying to but i'm getting PLS-00103 error. These are the errors that I'm getting when i run my code in DBVisaulzier: 18:00:09 [DECLARE - 0 row(s), 0.000 secs] [Error Code: 655...

distribution transaction lock in oracle database

Hi, I have some question around transaction lock in oracle database. What I have found out so far is that: Cause: The time to wait on a lock in a distributed transaction has been exceeded. This time is specified in the initialization parameter DISTRIBUTED_LOCK_TIMEOUT. Action: This situation is treated as a deadlock and the statement ...

How do I rename an Index in MySQL

I would like to rename an index. I've looked at the alter table documentation, but I can't figure out the syntax to simply rename an index. When doing it through the MySQL GUI, it drops the index, and creates a new one. While this works, I would like to avoid rebuilding the entire index just to change the name of an index. [ADDITIONA...

SQL to Schema Model

Is there a library out there that can input SQL create/schema statements and construct a XSD or some sort of in memory schema model. Even if it's a DataTable. It needs to have a binding to .NET. ...

Where to see SQL Server start/stop logs?

Hello everyone, I want to know where to see SQL Server start/stop logs for each instances and SQL Server agent/job start/stop logs? I am developing some tools to monitor SQL Server status. I am using SQL Server 2008 Enterprise. thanks in advance, George ...

Querying across schemas in Postgres

Hi, I am using Postgres and I have multiple schemas (i.e. S1 and S2). I would like to run a query that uses tables in S1 and S2. is it possible to do something like this: select * from S1.table1, S2.table2 Thanks for all replies. ...

SQL server database start/stop issue

Hello everyone, I am using SQL Server 2008 Enterprise for development. I find from SQL Server logs, there are items like, 2009-09-20 19:54:33.55 spid53 Starting up database 'DummyOrderDB'. My confusion is, I think we could only start/stop database server instance (the contained database will be started/stopped when the containin...

DB2: accessing the column by column number

Can I select the columns by column number like for example select custome.0, customer.1 from customer table customer with id and name as columns? ...

combine stored procedure in sql and my sql

am writing stored procedure in mysql 5.1 and call from c#.net ..and i want use that procedure in sql server..if its possible..please explain.. ...

SQL Server 2005 Database 'In Recovery'

This might be a bit of a naive question and probably something I should know by now but here goes.. I restored a 35Gb database on my dev machine yesterday and it was all going fine until this morning when my client app couldn't connect. So I opened SQL Management Studio to find the database 'In Recovery'. I don't know a huge amount a...

How to write a SQL Query for the following

I have 3 tables Teams, Players and TxP Teams table has the columns TeamName and TeamID(Primary Key) Players table has the columns PlayerName and PlayerID(Primary Key) TxP table has the columns PlayerID, TeamID I would like to write a query to get the result set as PlayerName, TeamName ...

selecting a particular field from a table?

I am using the following SQL query: Select * from table1 as t1, table2 as t2 where t1.id = t2.col but my problem is that both the tables have fields with same name, place. So how can I select the column with name place from table2 in my PHP code? I want to use the following php code while($row_records = mysql_fetch_array($result_rec...

How to find count of transaction of type1 and type2 for each customer in mysql

I have a customer table: id name 1 customer1 2 customer2 3 customer3 and a transaction table: id customer amount type 1 1 10 type1 2 1 15 type1 3 1 15 type2 4 2 60 type2 5 3 23 type1 What I want my query to return is the follo...

Oracle SQL: update table conditionally based on values in another table

[Previous essay-title for question] Oracle SQL: update parent table column if all child table rows have specific value in a column. Update RANK of only those students who have 100 marks in all the subjects. If student has less than 100 marks in any subject, his RANK should not be updated. I have a scenario where I have a parent table a...

Send email to DISTINCT email

Hi there, I have an Classic ASP page that lets users search for properties and a results page that then emails the property agents who have matching properties to let them know that there are tenants interested in their properties. Some agents may have more than 1 property, in which case the agent only needs to receive 1 email rather t...