2017 m. spalio 14 d., šeštadienis

SQL - Structured Query Language

The main categories are:
  • Data Definition Language (DDL) 
  • Data Manipulation Language (DML) - INSERT, UPDATE, DELETE 
  • Data Query Language (DQL) - SELECT 
  • Data Control Language (DCL) 
  • Data administration commands 
    • Transactional control commands 
    • COMMIT—Saves database transactions 
    • ROLLBACK—Undoes database transactions 
    • SAVEPOINT—Creates points within groups of transactions in which to 
    • ROLLBACK 
    • SET TRANSACTION—Places a name on a transaction

Very basic data types:
  • String types
  • Numeric types
    • BIT
    • DECIMAL
    • INTEGER
    • SMALLINT
    • BIGINT
    • FLOAT
    • DOABLE PRECISION
    • REAL
  • Date and time types
    •  DATE
    •  TIME
    •  DATETIME
    •  TIMESTAMP
  • Literal Strings
  • NULL

When using the NULL data type, it is important to realize that data is not required in a particular field. If data is always required for a given field,


Definitions
Acronyms:

Database Management system (DBMS)
Relational database management system (RDBMS)
Structured Query Language (SQL) 
American National Standards Institute (ANSI)

Open Database Connectivity (ODBC) 
JDBC is Java Database Connectivity (DBC)
Definitions:

Database is a collection of data.
Data is a collection of information stored in a database as one of several different data types.


A relational database is a database divided into logical units called tables, where tables are related to one another within the database.


A database object is any defined object in a database that is used to store or reference data.(tables, views, clusters, sequences, indexes, and synonyms)

A schema is a collection of database objects normally associated with one particular database username.

A transaction is a unit of work that is performed against a database accomplished using the Data Manipulation Language (DML) commands.
the transaction.

Three commands are used to control transactions:
  • COMMIT
  • ROLLBACK
  • SAVEPOINT

An aggregate
Function provides summarization information for an SQL statement, such as counts, totals, and averages.
  • COUNT
  • SUM
  • MAX/MIN
  • AVG
Character functions are functions that represent strings in SQL in formats different from the way they are stored in the table. 

Concatenation is the process of combining two strings into one. 

A subquery, also known as a nested query, is a query embedded within the WHERE clause of another query to further restrict data returned by the query.

Single query is one SELECT statement
Compound query includes two or more SELECT statements.

Index is a pointer to data in a table. (Like book index).

  • Single-Column Indexes
  • Unique Indexes
  • Composite Indexes
  • Implicit Indexes

SQL statement tuning is the process of optimally building SQL statements to achieve results in the most effective and efficient manner.

A trigger is a compiled SQL procedure in the database that performs actions based on other actions occurring within the database. 
Dynamic SQL allows a programmer or end user to create an SQL statement’s specifics at runtime and pass the statement to the database.