This is a very newbie question I fear... I was wondering if there are folks on here that can tell me what the difference is between SQL scripts and SQL queries (I've been inadvertently using these terms interchangeably for too long).
I have plenty of experience executing queries (SQL server, oracle, postgres), but I started working with a group that requires I submit scripts with said SQL queries through their department for review and explicitly told me not to send them queries, but the scripts. Can someone explain the difference for me?
If it matters, the SQL query I need to submit just joins fields from four tables together into one.
Thanks in advance if anyone can help me out with this!
This format is a way of directing output from a script to a file so that it can be copied into another script using the DEFINE SCRIPT command. If no output file is specified, the Tivoli® Storage Manager server outputs the "query script" with "format=raw" to the console.
Unlike a SQL query, which is a single statement or entity, a SQL script is a collection of two or more SQL statements. Its purpose is to group related statements together to accomplish a more complex goal.
The MPEG Query Format, also known as MPQF, facilitates a standard multimedia query language so that service providers can offer users and applications a unified interface for querying media repositories.
A statement is the general term for a piece of complete, correct SQL that you can send to a DBMS. A query is a statement that will return data, thus a query is a special kind of statement.
In this context it sounds like they want to see any set of commands that will be changing (INSERT, UPDATE, DELETE, etc.) data and are not concerned with any queries you're running to simply return or review data.
I suspect more people use these terms interchangeably than you think.
It's a very good idea to go back to this department unashamed and ask for clarification as different teams use different terms. I think you will find they're asking you to plan any data-changing action out in advance, put your commands in sequence in a file (like a .sql file if you work in Management studio, etc.) and forward that file to them for review.
Asking around was a great move. You cannot be too careful with these things!
A query consists of a single command. A script is just a file with a bunch of queries.
See: http://docs.oracle.com/cd/E14373_01/user.32/e13370/sql_rep.htm
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With