All Questions
28 questions
74
votes
4
answers
52k
views
Relationship between catalog, schema, user, and database instance
To compare databases of different vendors (Oracle, SQL Server, DB2, MySQL, and PostgreSQL) how can I identify any object uniquely and do I need a catalog? For instance, In Java's DatabaseMetadata I ...
0
votes
1
answer
172
views
Overlaying rows in SQL
So, I want to store sets of key-value pairs in a database and then retrieve a combined set of the key-value pairs based on a series of sets. Each set might not be complete.
Let's say we have a table ...
1
vote
2
answers
173
views
How to verify if DB remote server is running using only java raw sockets [Telnet]
I wanted to explore an option to write minimal code to check if db2 server is running using plain java sockets. Just like doing telnet to server. It seems db2 is not configured to respond for telnet ...
2
votes
8
answers
18k
views
Set default value in select statement(not use UNION statement)
I would like to have a SELECT statement that will return specified default values if no rows are returned from the database.
We can use UNION to get the desired result like this question: "How to ...
1
vote
2
answers
91
views
Is it really needed to define a column as foreign key in all tables where it is used
I have a users table which has user_id as primary key and it is used in other 40 to 50 tables(approx.).
Is it necessary to define user_id column as foreign key in each and every table where user_id is ...
1
vote
4
answers
6k
views
Compare table content with external file- SQL
I have an Excel file with users IDs, called users Excel.
In the Database I have a users table: this table holds the data from the users excel file and from another file (administrators file).
I ...
0
votes
1
answer
235
views
Developing a comprehensive set of SQL statements/queries based on Sakila or other standard database [closed]
I'm developing a comprehensive set of SQL statements/queries based on Sakila or other standard database.
I'm testing a number of DB Connectivity Drivers, against different DBs (i.e. MySQL, Oracle, ...
3
votes
3
answers
14k
views
SQL Using inner query in left join
I have the below two tables ONE & TWO
ONE TWO
ID ID CODE
----- ---------
1 1 1
2 1 2
3 2 1
4 3 1
5 ...
7
votes
2
answers
1k
views
Which DBMS's allow an order by of an attribute, that is not present in the select clause?
Let's assume I have a table called Cars with 2 columns: CarName, BrandName
Now I want to execute this query:
select CarName
from Cars
order by BrandName
As you can see, I'd like to return a list, ...
1
vote
2
answers
73
views
Select single row with multiple rows in joined table
I have a contact table as below:
contactid | contactname
----------|-------------
C1 | Name1
C2 | Name2
I have a communication table as below
contactid | communication_type | ...
4
votes
2
answers
1k
views
Is there a SQL select qualifier to perform a Skip() and Take()
We are trying to do the equivalent of a LINQ select.Skip(50).Take(25). This is for a library that can hit any SQL database. So...
Is there a standard SQL select clause that can do this? (Pretty sure ...
2
votes
3
answers
3k
views
separate queries in mysql, db2 and oracle
to separate queries in an sql file:
with mysql :
we can use
Delimiter /
example:
Delimiter /
select * from product;
/
select * from h_product;
/
Delimiter ;
insert into ptoduct(prod_name)values('...
3
votes
4
answers
244
views
SQL to group based on the counts of a column
A hypothetical table contains the following coloumns:
id integer,
name char(6),
status integer
And has the following data:
id id2 type
--- ----- ----
01 Adam 1
02 Bob 1
03 ...
-2
votes
2
answers
237
views
query to obtain final status as fail when any one of listed subject is failed
Select count(course),course,dept,
Case
When ****condition*** then 'passed'
Else 'failed'
End as finalstatus
from college group by course,dept;
Here condition should check each subject of each ...
2
votes
4
answers
1k
views
Insert query based on number of rows
I want a query to insert a row into a table I know it is simple but the scenario is the table should not have more than 5 rows. If table has more than five rows I need to remove the old row(Or replace ...