The Union query seems to be equivalent to: select sale_at, COALESCE(child_id,product_id ) from sale LEFT join split on(parent_id=product_id);
@JackDouglas So, in this example, you want to leave the 2 rows (with product_id=2 untouched) and the other 3 rows deleted and "split", so 6 new rows inserted in place of these 3?
The way I resolved this issue at my workplace is by introducing ROWLOCK and NOLOCK.
When you perform an insert or update on a particular table row, you add a ROWLOCK to it. This will prevent any other updates happening on the same row and the other update will wait until the row lock is released...
I'm still mentally frazzled so I might spout nonsense, but yes
@ypercube to that
I can do the insert and then the delete, but the problem is that another transaction might commit between the two, at least if I understand MVCC correctly
for the following data, I'd like to be able to delete some rows and insert others giving the result below. Is this possible with a single statement (eg with the merge statement)?
create table product(product_id integer primary key);
insert into product(product_id) values(1);
insert into product(...
Oracle's 'serializable' seems to do what I want (it ignores any rows inserted/comitted by another transaction between the insert and delete in the main transaction (but neither transaction fails)
@gbn yes, you default to something stricter than MVCC?
> Snapshot isolation is called "serializable" mode in Oracle[2][3][4] and PostgreSQL versions prior to 9.1,[5][6] which may cause confusion with the "real serializability" mode. There are arguments both for and against this decision; what is clear is that users must be aware of the distinction to avoid possible undesired anomalous behavior in their database system logic.
> Snapshot isolation has also been used[1] to critique the ANSI SQL-92 standard's definition of isolation levels, as it exhibits none of the "anomalies" that the SQL standard prohibited, yet is not serializable (the anomaly-free isolation level defined by ANSI).
> When using non-lock based concurrency control, no locks are acquired; however, if the system detects a write collision among several concurrent transactions, only one of them is allowed to commit. See snapshot isolation for more details on this topic.
In databases, and transaction processing (transaction management), snapshot isolation is a guarantee that all reads made in a transaction will see a consistent snapshot of the database (in practice it reads the last committed values that existed at the time it started), and the transaction itself will successfully commit only if no updates it has made conflict with any concurrent updates made since that snapshot.
Snapshot isolation has been adopted by several major database management systems, such as SQL Anywhere, InterBase, Firebird, Oracle, PostgreSQL and Microsoft SQL Server (2005 and ...
insert into sale(sale_at, product_id) select sale_at, child_id from sale join split on parent_id=product_id; delete from sale where product_id in (select parent_id from split);
delete from sale where product_id in
(
insert into sale(sale_at, product_id)
OUTPUT parent_id
select sale_at, child_id from sale join split on parent_id=product_id
) X;
delete from sale where product_id in
(
insert into sale(sale_at, product_id)
OUTPUT parent_id
select sale_at, child_id from sale join split on parent_id=product_id
) X;
Do it all in one with some composable DML?
INSERT INTO order_item (item_no, order_id)
SELECT
X.item_no, @order_id
FROM
(
MERGE INTO items AS tgt
USING
(SELECT TOP (@whatever) item_no
FROM items
WHERE status = 'Unused'
) AS src ON tgt.item_no = src.item_...
Can someone elaborate on what this feature is useful for?
Generating sequences, is that not obvious?
Stuff like account numbers, order numbers, order numbers - that may not even be used as identity as in identity column.
@bluefeet floorball (think like ice hockey without the ice, skates, padding or hitting and you're fairly close), football (soccer), indoor football, ultimate frisbee and rock climbing (only indoor wall climbing so far, not brave enough for actual rock climbing yet)
@Marian Also that - NHL 13 and FIFA 12 ;) Not sure if I'm going to buy a PS4 at launch or not (definitely not buying the new Xbox, screw that)
@SimonRigharts well I will definitely buy it sometimes near Christmas, if I can grab it. I hate XBox's live connection stuff. The PS3 I have now was brilliant for some games.
@SimonRigharts don't know about their used game policy, but the only thing I liked about the current XBOX was the camera stuff. That was indeed fine, not the shitty Eye thing from Sony. But games sucked hard.
I have a table like
NAME | TABLE_NAME
-----------------
X1 | X001
X2 | X002
This table contains a name column which is nothing but description and a table_name column which is actually a table already present in the database.
X001 Table has columns like X1_A, X1_B
X002 Table has columns...
There are a lot of Questions and Answers on how to fine tune a query. They pretty much all assume you have some intelligence and have done your best to create a good query.
My question is how do you optimize a query for inefficiency? What basic types of SQL query language will cause the most ...
42 (forty-two) is the natural number immediately following 41 and directly preceding 43. The number has received considerable attention in popular culture as a result of its central appearance in The Hitchhiker's Guide to the Galaxy as the "Answer to the Ultimate Question of Life, the Universe, and Everything".
Mathematics
* Forty-two is a pronic number and an abundant number; its prime factorization 2 · 3 · 7 makes it the second sphenic number and also the second of the form { 2 · 3 · r }. As with all sphenic numbers of this form, the ...
I swear sometimes I'm the only person on SO who cares to teach people proper programming.
The design in the OP is flawed. You should go for a 3NF design as per below (see http://en.wikipedia.org/wiki/Third_normal_form):
/* Table for unique voters */
CREATE TABLE voters (
id INT UNSIGNED NO...
That user totally went after my initial answer when I wasn't even done editing.
I was about to down-vote for your obnoxious statement that you are the only person on StackOverflow capable of guiding users to better "programming" even though the problem here is schema design. Thank you for removing it. — Aaron Bertrand15 secs ago
@AaronBertrand I think the first comment was funnier even.
@StevenMoseley Guy, sometimes the schema is fixed, and users are stuck with it and can't just rebuild the entire application at the whim of some know-it-all on StackOverflow. — Aaron Bertrand5 mins ago
I don't know of a place. Different people provide different help; if we were all robots doing the same thing, every question would have exactly one answer. I strongly recommend not going around down-voting people because their answers aren't as good as yours, or stating that you're the only person on StackOverflow that cares. It's pretty demeaning to everyone around you. — Aaron Bertrand23 secs ago
@AaronBertrand Has becoming a mod made you more mellow?
3
You can't always train a user on proper database design in response to a single question. You can't always teach someone to fish, and not everyone wants to learn how to fish. And you shouldn't lash out at others just because they're not as altruistic as you (and if you want to keep being that way, at least give them time to finish their answer before you start griping about it). — Aaron Bertrand7 mins ago
eed help in below table updation using SQL in Ms-Access 2007 database.
I've a table called table1 which has below entries:
table1:
--------------------------------------------------
| col1 | col2 | col3 | Col4
-------------------------------------------------
| A1 | ...
today (one hour ago) I post a question History from SQL Agent Jobs (SQL Server 2005)
all notification about new answer(s)/commnents were accesible only when I checked my question on Database Administrators site manually, not notified outside of Database Administrators
during this time (question ...
I have a table called products.
ProductId| ProductName| ProductType| ProductSize
1 | a | yellow | 12
2 | b | green | 13
3 | c | yellow | 12
4 | d | yellow | 15
I want to get count of each product as a column at...
Got accepted for SQLSaturday Baton Rouge. Same talk as 2 years ago. But not in the crack of dawn slot - before lunch so hopefully a good alert crowd...
@Zane Metadata - code generation and using extended properties for tagging database objects. Basically, table driven code generation, either for dynamic SQL or tooling up SQL through codegen. It's a beginning-intermediate talk - just working smarter, basically. There are lots of applications, but it basically touches on using extended properties instead of tables of tables if you want to make sure when tables or columns are dropped that the metadata doesn't hang around and cause problems.
@Marian Not really. It was just a combination of the layering and metadata idea and using tools to do the heavy lifting.
Logo is a multi-paradigm computer programming language used in education. It is an adaptation and dialect of the Lisp language. It was originally conceived and written as a functional programming language, and drove a mechanical turtle as an output device. It also has significant facilities for handling lists, files, I/O, and recursion. Today it is remembered mainly for its turtle graphics, though for tertiary level teaching it has been superseded by Scheme, and scripting languages.
Logo was created in 1967 for educational use, more so for constructivist teaching, by Daniel G. Bobrow, W...
Zeno (after pre-Socratic Greek philosopher Zeno of Elea) is an imperative procedural programming language designed to be easy to learn and user friendly. Zeno is generic in the sense that it contains most of the essential elements used in other languages to develop real applications.
The Zeno Interpreter was designed for use in Windows 95 and later Microsoft operating systems. The interpreter comes with built-in debugging tools, a source code text editor, and an on-line language reference.
Zeno was created by Stephen R. Schmitt and is maintained by Abecedarical Systems.
Example: Sieve o...
ZOPL is a programming language created by Geac Computer Corporation in the early 1970s for use on their mainframe computer systems used in libraries and banking institutions. It had similarities to C and Pascal.
ZOPL stood for "Version Z, Our Programming Language".
ZOPL is still in use at CGI Group (formerly known as RealTime Datapro), who ported it to VAX/VMS and Unix in the 1980s, and to Windows in 1998. It currently (2010) runs on Windows XP/2000/2003 and Red Hat Linux. The RTM (formerly ZUG) language compiler and runtime framework are written in ZOPL.
Outside of CGI, ZOPL has not...
ZPL (short for Z-level Programming Language) is an array programming language designed to replace C and C++ programming languages in engineering and scientific applications. Because its design goal was to obtain cross-platform high performance, ZPL programs run fast on both sequential and parallel computers. Highly-parallel ZPL programs are simple and easy to write because it exclusively uses implicit parallelism.
Originally called Orca C, ZPL was designed and implemented during 1993-1995 by the Orca Project of the Computer Science and Engineering Department at the University of Washingto...
One of my projects never really started: PREZQL - Presentation Query Language for cross management of queries and presentations. Generate your PowerPoint from your SQL and be able to demo queries and return to the presentation.
@CadeRoux Abso-effing-lutely - The system has a perfectly good data dictionary and metadata updates tend to fall in the cracks. I do quite a bit of stuff that generates code off the back of markup in the system data dictionary. Another argument I've had to have far too many times - "No, we are not going to deploy and maintain a 17 table configuration database for the ETL framework."
I have a table: OrderDetails.
For 5 years, only the odd Deadlock has occured.
If it happened, it happened on indexes which was on OrderDetails table
Now all of a sudden, deadlocks are everywhere - happens very minute.
We have not made any changes to the application or database - the indexes reb...
We have a new account like @sweden in New Orleans called @BeingNOLA in its second week: twitter.com/BeingNOLA - I am lined up for week of July 7. There are already three parody accounts for the neighboring suburbs: @BeingMetairie, @BeingLakeview, @BeingKenner.
@PaulWhite Flicked through the slide pack from IE2 this afternoon. One of the call-outs in the IO module is "Misconception that SQL Server always reads extents". Funny as I daresay Paul is the person Denny is referring to in his comment :)