Você está na página 1de 4

SQL

SQL is the abbreviation of structured query language. It is a special purpose programming language for managing data in relational database management system. SQL can insert data into database tables. SQL can modify data in existing database tables. SQL can delete data from SQL database tables. Finally SQL can modify the database structure itself create/modify/delete tables and other database objects. SQL was initially developed at IBM by Donald D Chamberlin and Raymond F. Beyoce in the early 1970s. This version was initially called SEQUEL (Structured English Query Language). Most Relational Database Management Systems like MS SQL Server, Microsoft Access, Oracle, MySQL, DB2, Sybase, PostgreSQL and Informix use SQL as a database querying language. Even though SQL is defined by both ISO and ANSI there are many SQL implementation, which do not fully comply with those definitions. Some of these SQL implementations are proprietary. Examples of these SQL dialects are MS SQL Server specific version of the SQL called T-SQL and Oracle version of SQL called PL/SQL. The SQL language is based on several elements: Clauses: The clauses are components of the statements and the queries. Expressions: The expressions can produce scalar values or tables, which consist of columns and rows of data. Queries: Queries retrieve the data based on specific criteria. This is the most important element of SQL. Predicates: which specify conditions that can be evaluated to SQL three- valued logic (3vl) or Boolean (true/false/unknown) truth values and which are used to limit the effects of statements and queries, or to change program flow. Statements: with the statements one can control transactions, program flow, connections, sessions, or diagnostics. In database systems the SQL statements are used for sending queries from a client program to a server where the databases are stored. In response, the server processes the SQL statements and returns replies to the client program. This allows users to execute a wide range of amazingly fast data manipulation operations from simple data inputs to complicated queries.

Queries: Query is the most common operation in SQL. Basically, all SQL code is written in the form of a query statement and then executed against a database. All SQL queries perform some type of data operation such as selecting data, inserting/updating data, or creating data objects such as SQL databases and SQL tables. SELECT queries are the most commonly used SQL commands. SELECT retrieves data from one or multiple tables and expressions. SELECT is the most complex statement in SQL, with optional keywords and clauses that include: FROM, WHERE, HAVING, ORDER BY etc. Subqueries: A query nested inside a SELECT statement is known as a subquery and is an alternative to complex join statements. A subquery combines data from multiple tables and returns results that are inserted into the WHERE condition of the main query. A subquery is always enclosed within parentheses and returns a column. A subquery can also be referred to as an inner query and the main query as an outer query. Data Manipulation Language The Data Manipulation Language (DML) contains the subset of SQL commands used most frequently those that simply manipulate the contents of a database in some form. The four most common DML commands are used to retrieve information from a database (the SELECT) command, add new information to a database (the INSERT command), modify information currently stored in a database (the UPDATE command) and remove information from a database (the DELETE command). The Data Definition Language (DDL): It contains commands that are less frequently used. DDL commands modify the actual structure of a database, rather than the databases contents. Examples of commonly used DDL commands include those used to generate a new database table (CREATE TABLE), modify the structure of a database table (ALTER TABLE), and delete a database table (DROP TABLE). Data Control Language The Data Control Language (DCL) is used to manage user access to databases. It consists of two commands: the GRANT command, used to add database permissions for a user, and the REVOKE

command, used to take away existing permissions. These two commands form the core of the relational database security model.

Você também pode gostar