Questions about several SQL commands [closed] - sql

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 8 years ago.
Improve this question
I am working on my database class project. I am reading the PostgreSQL Write-ahead-logging README, it mentioned several commands such as SQL commands
BEGIN
COMMIT
ROLLBACK
SAVEPOINT
ROLLBACK
RELEASE
In the SQL standard, I didn't see those commands. I am confused by that. What's the differences between those commands and standard "SELECT"? Could anyone tell me more about those commands? Can those commands be used the same way as standard SQL?

The ANSI SQL Standard [http://www.contrib.andrew.cmu.edu/~shadow/sql/sql1992.txt] is also your friend, and you can find these keywords defined there.
Generally all these keywords behave similarly across platforms, but beware the subtle differences in their function, performance or usage.
For example: SAVEPOPINT has similar meanings across different platforms (albeit possibly differing implementations or context), so you need to refer to your platform docs for specifics.
In this case, the Postgres 9.1 manual [http://www.postgresql.org/docs/9.1/] (the one I have bookmarked) ROLLBACK and RELEASE keywords are used together with other modifiers to apply to a SAVEPOINT within a transaction.
OTOH: T-SQL (MS-SQL Server) requires SAVE|ROLLBACK TRANSACTION when operating on a SAVEPOINT [http://msdn.microsoft.com/en-us/library/ms188378.aspx].
Hope that helps!

Related

How to verify if two databases are identical using SQL Server Management Studio [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 5 years ago.
Improve this question
I have two databases in two networks. I want to check one against another for to see table definition mismatches. I have database definition scripts of both databases. Is there any built-in function in SQL Server to achieve this.?
All the configurations in database servers are similar. The server version is SQL Server 12.0.2.
Update: I know there are text comparison tools, and I use beyond compare.
If you have the database definition scripts the easy way is to use diff on the UNIX (or Mac) command line, or windiff in Windows (see https://answers.microsoft.com/en-us/windows/forum/windows_10-files-winpc/does-windiff-exec-available-in-windows-10-64-bit/624fb262-7cba-49bd-b02e-74814a4d11b6?auth=1).
Otherwise you can use a database design tool. There are many available but they all cost a lot more than using diff.

Oracle PL SQL command-line utility [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
Is there any kind of program on oracle which helps you with typing?
For example there is SQL Prompt on MS SQL Server, and I want to know if there is something like this on PL/SQL Developer.
The Oracle ecosystem is slightly different in approach from MS SQL Server. Traditionally Oracle has offered a top-notch RDBMS but its supporting tools have been rather basic, with third-party vendors filling in the gap. This contrasts with the MS approach which offers tightly integrated environments for managing and developing against MSSQL.
So yes, PL/SQL Developer (the Allround Automations product) has code completion for PL/SQL and SQL elements. Quest TOAD has it too. Oracle came late to the IDE game but its Oracle SQL Developer product does code completion. Finally, the new Oracle SQL Command Line tool offers statement completion, which is another reason it is superior to the venerable SQL*Plus tool.
These are all separate tools, even the Oracle ones, until Oracle 12cR2 which does bundle SQLcl in the download.

How to improve the performance of the package [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 5 years ago.
Improve this question
I have been asked to improve the package performance without affecting the functionality.How to start with optimisation ?Any suggestions
In order to optimize PL/SQL programs you need to know where they spend time during execution.
Oracle provide two tools for profiling PL/SQL. The first one is DBMS_PROFILER. Running a packaged procedure in a Profiler session gives us a breakdown of each program line executed and how much time was spent on each line. This gives us an indication of where the bottlenecks are: we need to focus on the lines which consume the most time. We can only use this on our own packages but it writes to databases tables so it is easy to use. Find out more.
In 11g Oracle also gave us the Hierarchical Profiler, DBMS_HPROF. This does something similar but it allows us to drill down into the performance of dependencies in other schemas; this can be very useful if your application has lots of schemas. The snag is the Hprofiler writes to files and uses external tables; some places are funny about the database application writing to the OS file system. Anyway, find out more.
Once you have your profiles you know where you need to start tuning. The PL/SQL Guide has a whole chapter on Tuning and Optimization. Check it out.
" without affecting the functionality."
Depending on what bottlenecks you have you may need to rewrite some code. To safely change the internal workings of PL/SQL without affecting the external functionality(same outcome for same input) you need a comprehensive set of unit tests. If you don't have these already you will need to write them first.

Trigger code is written in [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
Trigger code is written in:
SQL
PL/SQL
JAVA
Machine Language
I think options of this question is wrong, bcoz option 1 and 2 are correct. I know only one thing is that we use SQL in terms of MS SQL,MY SQL, Sybase whereas PL/SQL uses in Oracle. please correct me with exact opinion about this question?
Let's clarify each option:
1) Structured Query Language - used for communication with databases, and CRUD operations. Triggers are not written in SQL.
2) PL/SQL - language which used in Oracle databases, procedural language which is extension of SQL. PL/SQL has exact block structure which called trigger, which is implicitly started when an INSERT, UPDATE or DELETE statement is issued against an associated table.
3) Java is object oriented, cross-platforming high-level language. You can create some trigger-like stuff in Java, but in general it doesn't have trigger units.
4) Machine language is instructions which are executed directly on CPU for solving specific task.
So, option 2 is exactly matches the answer.

Difference between Script, Stored Procedure, T-SQL, PL/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 8 years ago.
Improve this question
I'm getting really confused with all these terms. I used to attend a class called PL/SQL, then when I came out to work, I came across other terms like Stored Procedure, T-SQL and even script. They all look very similar to me, but exactly what are the differences between each of them? (if any)
Here's some rough definitions to explain the differences.
PL/SQL - a SQL variation specific to Oracle databases.
T-SQL (Transact-SQL) - a SQL variation specific to Microsoft (and Sybase) databases.
Stored Procedure - a set of SQL commands that is precompiled and stored on the server for reuse
Script - a set of SQL commands that is run ad-hoc (not precompiled / not meant for reuse)
There are more differences between Stored Procedures and Scripts (e.g. sprocs can have parameters, etc.) but that's the fundamental difference.
T-SQL is Microsoft's version of SQL. PL/SQL is Oracle's version of SQL. Both are ANSI SQL compliant, but contain additional capabilities that are not in the standard.
A Stored Procedure is a prepared SQL statement that is stored on the database server, and can be reused by calling it.
Script is basically code, but scripts are typically small, standalone programs that operate without the aid of a GUI. A Stored Procedure could properly be called a script.