I looking very large database for Oracle [closed] - sql

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 2 years ago.
Improve this question
I need to very large sample databaset for Oracle like Microsoft's AdwentureWorks or WideWorldImporters. I searched but didn't find. Can you help me please? By the way I know to HR or other samples.

You can create your own tables with large numbers of rows very easily using a statement like the one below. Just change the 1000 to however many rows you want in the table.
CREATE TABLE test_table
AS
SELECT LEVEL AS id,
DBMS_RANDOM.STRING ('p', ROUND (DBMS_RANDOM.VALUE (10, 50))) AS val1,
DBMS_RANDOM.STRING ('x', ROUND (DBMS_RANDOM.VALUE (100, 200))) AS val2
FROM DUAL
CONNECT BY LEVEL <= 1000;

here is some sample databases , hopefully is useful:
https://www.oracle.com/database/technologies/spatial-graph-here-data-downloads.html
or this one:
https://github.com/oracle/db-sample-schemas
The schemas are:
HR: Human Resources
OE: Order Entry
PM: Product Media
IX: Information Exchange
SH: Sales History
BI: Business Intelligence

Related

How to you use Max and Min expression in Ms Access SQL? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
CrimeData Table for 12 months
Crime Took place in Easternmost
I need to find the following:
Q.7 What type of Crime takes place in the …
(a) Easternmost ………………..
(b) Westernmost ………………..
(c) Northernmost………………..
(d) Southernmost………………..
I tried to find the crime took place in the Easternmost using the following SQL code
SELECT Max(CrimeData.Easting) AS MaxOfEasting, CrimeData.Type
FROM CrimeData
GROUP BY CrimeData.Type;
but I got more than one crime and also other Easting numbers. Can you please tell me if there are other good ways to find the solution.
Please see the attached pictures :)
Rather than using Max/Min, have a look at the TOP keyword in SQL. Some SQL might look like:
SELECT TOP 1 CD.*
FROM CrimeData CD
ORDER BY CD.Easting DESC;
Regards,

Database design for Question-Answer-User entity. Especially where N-Level of Nested question is possible [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 3 years ago.
Improve this question
I end up with complex db design issue of user's question/answer & thought to take your help or suggestions. It looks it's rare case which generally appear.
A User should be able to provide offered question's answer (Up to here looks easy & good). Now we have a kind of requirement where we would offering N-levels of nested questions.
Let me explain it by an example,
Question - 1 : What's your favourite food ? (Very simplest - level -1)
Question - 2 : Do you like football match ? (Level - 1 )
Yes ? No ? (Level-1.1 or call it 2nd nested level)
if No then Why ? (Level - 1.1.1 or call it 3nd nested level)
So likewise, as of now we have up to 5-nested level of question bank and for which I want your opinion/suggestion about how do we do this?
Any suggestion would be much appreciable !!
You just need to have a ParentQuestionId on the Question table. This can be NULL for top level questions.
eg:
Question Id: 1
ParentId: NULL
Text: Do you like football match?
Question Id: 2
ParentId: 1
Text: If No then Why?
This allows unlimited nesting, and unlimited questions per level assuming all questions have at most one parent, which seems to make sense to me...
This is a standard Tree Hierarchy so you should be able to find examples for this design and queries supporting it quite easily.

Tool to convert a SQL query into a visual diagram? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
Improve this question
I have a bunch of Oracle SQL queries I'd like to prepare some visual model / diagrams for. For example, to show all of the tables, the joins, and the join conditions.
Does such a tool exist?
Yes, Oracle SQL Developer, and it's included with your license of Oracle Database...in other words, it's free.
Bonus, it's Java, so will run on Windows, OS X, and Linux.
Open a connection, this give you a SQL Worksheet.
Type your query, example:
select b.extra_column
,b.department_id
,b.department_name
,b.manager_id
,b.location_id
,c.employee_id
,c.first_name
,c.last_name
,c.email
,c.phone_number
,c.hire_date
,c.job_id
,c.salary
,c.commission_pct
,c.manager_id
,c.department_id
,a.location_id
,a.street_address
,a.postal_code
,a.city
,a.state_province
,a.country_id
from departments b
,locations a
,employees c
where a.location_id = b.location_id
and c.employee_id = b.manager_id
and b.department_id = c.department_id;
Click the Query Builder tab.
Voila.
Note there is a performance bug in current version, will be fixed for version 18.2. In other words, it will take a few moments to render the diagram for you today.
Also this, from the SQL text only with no need to create the tables: https://sqldep.com/

ZF2 sql count rows with different values [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Improve this question
I'm developing an application in zend framework 2 ans need to get some count values from a database table.
the table contains members with a column 'active' and 'blocked'
i would like te get the total number of members as well as the number of active and the number of blocked members.
Note that there will be a big amount of members in the table, so 'slow solutions' are not a option.
thanx for the help!
With those 2 columns, you would need to do something like:
SELECT SUM(active) as nrActive, SUM(if(blocked = 'yes', 1, 0)) as nrBlocked FROM members;
In this example "active" can have value 0 or 1, for blocked I assumed 'yes' and 'no', this way you have an example of both situations.
In ZF2 you can compose a query using Zend\Sql
$sql = new \Zend\Db\Sql($dbAdapter);
$sql->from('members', array(
'nrActive' => new \Zend\Db\Sql\Expression('SUM(active)'),
'nrBlocked' => new \Zend\Db\Sql\Expression('SUM(if(blocked = "yes", 1, 0))')
);
(disclaimer: I wrote this off hand so can have typo's, just for example)

Tool for making diagram from SQL query [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 8 years ago.
Improve this question
I have this complicated SQL query for Oracle that I want to visualize in a diagram to make it understandable for my co-workers. I tried at http://snowflakejoins.com but it just chokes on it.
Has someone a better suggestion? I prefer a web-app on the internet and if not a desktop app for windows.
with
logs as (
select
l.job_id,
l.subjob,
sum(l.verwerkt) verwerkt,
sum(l.errors) errors,
max(l.datum) laatst
from
dinf_monitor_logs l,
dinf_monitor_jobs j
where
l.datum>sysdate-j.dagen
and j.job_id=l.job_id(+)
group by
l.job_id,
l.subjob
),
alllogs as (
select job_id, subjob, max(datum) laatst from dinf_monitor_logs group by job_id, subjob
)
select row_number() over(order by alllogs.job_id, alllogs.subjob) r,
alllogs.job_id,
alljobs.naam,
alllogs.subjob,
logs.verwerkt,
logs.errors,
alllogs.laatst datum,
alljobs.wikilink,
alljobs.loglink,
alljobs.contact,
case
when alllogs.laatst is null then 1
when round(sysdate-(alllogs.laatst+alljobs.dagen))<0 then 0
else round(sysdate-(alllogs.laatst+alljobs.dagen))
end overtijd,
case
when logs.errors-alljobs.max_errors>0 then 5
when logs.verwerkt-alljobs.min_verwerkt<0 then 7
when round(sysdate-(alllogs.laatst+alljobs.dagen))>0 then 3
else 11
end status
from logs, alllogs, (select job_id, naam, wikilink, loglink, contact, dagen, min_verwerkt, max_errors from dinf_monitor_jobs) alljobs
where
logs.job_id(+)=alllogs.job_id
and logs.subjob(+)=alllogs.subjob
and alllogs.job_id=alljobs.job_id
order by alllogs.job_id, alllogs.subjob
You can use the "Query Builder" tab of the Oracle's SQL Developer.
The result of your sample query will be:
Each of the sub queries are data sets, I would just make a plain English statement of what the query does, then describe the data sets and how they relate to one another in an entity-relationship manner, then show how the query satisfies the plain English statement. You can represent the E-R with any variety of tools.
Have found how to do it in Toad, which i prefer above Sql Developer.
Open the editorwindow, paste the sql, rightclick in the editorwindow and select "Send to queryviewer"
My sql above is too complicated to use this technique but it's nice to know i can use it in the future with more "normal" queries.
Points to Sergio.