Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Need help understanding the difference between a script format and query

Tags:

database

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!

like image 319
user1397044 Avatar asked Oct 12 '12 20:10

user1397044


People also ask

What is a query script?

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.

What is the difference between SQL query and SQL script?

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.

What is query format?

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.

What is the difference between query and statement?

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.


2 Answers

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!

like image 93
MitchellTR Avatar answered Oct 03 '22 19:10

MitchellTR


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

like image 45
Difusio Avatar answered Oct 03 '22 17:10

Difusio