Skip to content

Tag: sql

Joining multiple tables in SQL

Can sombody Explains me about joins? Inner join selects common data based on where condition. Left outer join selects all data from left irrespective of common but takes common data from right table and vice versa for Right outer. I know the basics but question stays when it comes to join for than 5, 8, 10 ta…

How to kill/stop a long SQL query immediately?

I am using SQL server 2008 and its management studio. I executed a query that yields many rows. I tried to cancel it via the red cancel button, but it has not stopped for the past 10 minutes. It usually stops within 3 minutes. What could the reason be and how do I stop it immediately ? Answer What could

Defining size of CLOB in Oracle

I am making a table in which I am storing XML. To store XML I am using CLOB data type. The max size of my XML would be 5kb. What size of CLOB column should I define while creating the table? Answer you don’t define a size exactly when setting a clob (unlike a varchar). it is just simply clob.

check if the column value exists in subquery

i have 3 tables Product Category and ProductCategory. Product table: Category table: ProductCategory: I need a query which returns products which fall under more than 1 categories. Based on the table data above the result would be: So i wrote a query to fetch all the ProductID’s which have more than one…

How to guarantee atomic SQL inserts with subqueries?

Given a simplified table structure like this: Can I use a subquery like this for inserting records without causing a race condition? Or are subqueries not atomic? I’m worried about simultaneous INSERTs grabbing the same value for num and then causing a unique constraint violation. Answer Yes, this can m…