Sunday, December 18, 2016

SQL

             SQL (pronounced "ess-que-el") stands for Structured Query Language. SQL is used to communicate with a database. According to ANSI (American National Standards    Institute), it is the standard language for relational database management systems. SQL statements are used to perform tasks such as update data on a database, or retrieve data from a database. Some common relational database management systems that use SQL are: Oracle, Sybase, Microsoft SQL Server, Access, Ingres, etc. Although most database systems use SQL, most of them also have their own additional proprietary extensions that are usually only used on their system. However, the standard SQL commands such as "Select", "Insert", "Update", "Delete", "Create", and "Drop" can be used to accomplish almost everything that one needs to do with a database. This tutorial will provide you with the instruction on the basics of each of these commands as well as allow you to put them to practice using the SQL Interpreter.

SQL stands for Structured Query Language
  • SQL lets you access and manipulate databases
  • SQL is an ANSI (American National Standards Institute) standard

What Can SQL do?
  • SQL can execute queries against a database
  • SQL can retrieve data from a database
  • SQL can insert records in a database
  • SQL can update records in a database
  • SQL can delete records from a database
  • SQL can create new databases
  • SQL can create new tables in a database
  • SQL can create stored procedures in a database
  • SQL can create views in a database
  • SQL can set permissions on tables, procedures, and views


source
https://en.wikipedia.org/wiki/SQL
http://www.w3schools.com/sql/sql_intro.asp
http://www.sqlcourse.com/intro.html

SQL Syntax



SQL - Syntax
SQL is followed by unique set of rules and guidelines called Syntax. This tutorial gives you a quick start with SQL by listing all the basic SQL Syntax:
All the SQL statements start with any of the keywords like SELECT, INSERT, UPDATE, DELETE, ALTER, DROP, CREATE, USE, SHOW and all the statements end with a semicolon (;).
Important point to be noted is that SQL is case insensitive, which means SELECT and select have same meaning in SQL statements, but MySQL makes difference in table names. So if you are working with MySQL, then you need to give table names as they exist in the database.
All the examples given in this tutorial have been tested with MySQL server.

SQL SELECT Statement:

SELECT column1, column2....columnN
FROM   table_name;

SQL DISTINCT Clause:

SELECT DISTINCT column1, column2....columnN
FROM   table_name;

SQL WHERE Clause:

SELECT column1, column2....columnN
FROM   table_name
WHERE  CONDITION;

SQL AND/OR Clause:

SELECT column1, column2....columnN
FROM   table_name
WHERE  CONDITION-1 {AND|OR} CONDITION-2;

SQL IN Clause:

SELECT column1, column2....columnN
FROM   table_name
WHERE  column_name IN (val-1, val-2,...val-N);

SQL BETWEEN Clause:

SELECT column1, column2....columnN
FROM   table_name
WHERE  column_name BETWEEN val-1 AND val-2;

SQL LIKE Clause:

SELECT column1, column2....columnN
FROM   table_name
WHERE  column_name LIKE { PATTERN };

SQL ORDER BY Clause:

SELECT column1, column2....columnN
FROM   table_name
WHERE  CONDITION
ORDER BY column_name {ASC|DESC};

SQL GROUP BY Clause:

SELECT SUM(column_name)
FROM   table_name
WHERE  CONDITION
GROUP BY column_name;

SQL COUNT Clause:

SELECT COUNT(column_name)
FROM   table_name
WHERE  CONDITION;

SQL HAVING Clause:

SELECT SUM(column_name)
FROM   table_name
WHERE  CONDITION
GROUP BY column_name
HAVING (arithematic function condition);

SQL CREATE TABLE Statement:

CREATE TABLE table_name(
column1 datatype,
column2 datatype,
column3 datatype,
.....
columnN datatype,
PRIMARY KEY( one or more columns )
);

SQL DROP TABLE Statement:

DROP TABLE table_name;

SQL CREATE INDEX Statement :

CREATE UNIQUE INDEX index_name
ON table_name ( column1, column2,...columnN);

SQL DROP INDEX Statement :

ALTER TABLE table_name
DROP INDEX index_name;

SQL DESC Statement :

DESC table_name;

SQL TRUNCATE TABLE Statement:

TRUNCATE TABLE table_name;

SQL ALTER TABLE Statement:

ALTER TABLE table_name {ADD|DROP|MODIFY} column_name {data_ype};

SQL ALTER TABLE Statement (Rename) :

ALTER TABLE table_name RENAME TO new_table_name;

SQL INSERT INTO Statement:

INSERT INTO table_name( column1, column2....columnN)
VALUES ( value1, value2....valueN);

SQL UPDATE Statement:

UPDATE table_name
SET column1 = value1, column2 = value2....columnN=valueN
[ WHERE  CONDITION ];

SQL DELETE Statement:

DELETE FROM table_name
WHERE  {CONDITION};

SQL CREATE DATABASE Statement:

CREATE DATABASE database_name;

SQL DROP DATABASE Statement:

DROP DATABASE database_name;

SQL USE Statement:

USE database_name;

SQL COMMIT Statement:

COMMIT;

SQL ROLLBACK Statement:

ROLLBACK;
Source https://www.tutorialspoint.com/sql/sql-syntax.htm

Relational database management system

A relational database management system (RDBMS) is a database management system (DBMS) that is based on the relational model as invented by E. F. Codd, of IBM's San Jose Research Laboratory. In 2016, many of the databases in widespread use are based on the relational database model.
RDBMSs have been a common choice for the storage of information in new databases used for financial records, manufacturing and logistical information, personnel data, and other applications since the 1980s. Relational databases have often replaced legacy hierarchical databases and network databases because they are easier to understand and use. However, relational databases have received unsuccessful challenge attempts by object database management systems in the 1980s and 1990s (which were introduced trying to address the so-called object-relational impedance mismatch between relational databases and object-oriented application programs) and also by XML database management systems in the 1990s.[citation needed] Despite such attempts, RDBMSs keep most of the market share, which has also grown over the years.

Market share

According to DB-Engines, in 2016, the most widely used systems are Oracle, MySQL (open source), Microsoft SQL Server, PostgreSQL (open source), IBM DB2, Microsoft Access, and SQLite (open source).[1]
According to research company Gartner, in 2011, the five leading commercial relational database vendors by revenue were Oracle (48.8%), IBM (20.2%), Microsoft (17.0%), SAP including Sybase (4.6%), and Teradata (3.7%).[2]
According to Gartner, in 2008, the percentage of database sites using any given technology were (a given site may deploy multiple technologies):[3]

Database Management System vs. Relational Database Management System:

The below table lists downs some of the major differences between DBMS and RDBMS.
Sl.#DBMSRDBMS
1 Introduced in 1960s. Introduced in 1970s.
2 During introduction it followed the navigational modes (Navigational DBMS) for data storage and fetching. This model uses relationship between tables using primary keys, foreign keys and indexes.
3 Data fetching is slower for complex and large amount of data. Comparatively faster because of its relational model.
4 Used for applications using small amount of data. Used for huge applications using complex and large amount of data.
5 Data Redundancy is common in this model leading to difficulty in maintaining the data. Keys and indexes are used in the tables to avoid redundancy.
6 Example systems are dBase, Microsoft Acces, LibreOffice Base, FoxPro. Example systems are SQL Server, Oracle , MySQL, MariaDB, SQLite.

A List of Relational Database Management System Examples

List of top 10 relational database management system example.If relation between object is defined in the form of table then its called Relational Database management systems. Here is top 10 examples of Relational database management systems.
  1. Oracle
  2. MySQL
  3. Microsoft SQL server
  4. PostgreSQL
  5. DB2
  6. Microsoft access
  7. Sq Lite
  8. Sybase
  9. Tera data
  10. Fire bird

http://technicgang.com/relational-database-management-system-examples/
 http://www.mytecbits.com/microsoft/sql-server/what-is-dbms-what-is-rdbms
https://en.wikipedia.org/wiki/Relational_database_management_system

Free PDF books Sql and database

An Introduction to Relational Database Theory



SQL: A Comparative Survey

Download here 

Best Books in Sql



SQL in 24 Hours, Sams Teach Yourself 

In just 24 sessions of one hour or less, you’ll learn how to use SQL to build effective databases, efficiently retrieve your data, and manage everything from performance to security! Using this book’s straightforward, step-by-step approach, you’ll learn hands-on through practical examples. Each lesson builds on what you’ve already learned, giving you a strong real-world foundation for success. The authors guide you from the absolute basics to advanced techniques—including views, transactions, Web data publishing, and even powerful SQL extensions for Oracle and Microsoft SQL Server!
Step-by-step instructions carefully walk you through the most common SQL tasks.
Quizzes and Exercises at the end of each chapter help you test your knowledge.
By the Way notes present interesting information related to the discussion.
Did You Know? tips offer advice or show you easier ways to perform tasks.
Watch Out! cautions alert you to possible problems and give you advice on how to avoid them.

 


SQL in 10 Minutes, Sams Teach Yourself

Sams Teach Yourself SQL in 10 Minutes, Fourth Edition
New full-color code examples help you see how SQL statements are structured 
Whether you're an application developer, database administrator, web application designer, mobile app developer, or Microsoft Office users, a good working knowledge of SQL is an important part of interacting with databases. And Sams Teach Yourself SQL in 10 Minutes offers the straightforward, practical answers you need to help you do your job.
Expert trainer and popular author Ben Forta teaches you just the parts of SQL you need to know–starting with simple data retrieval and quickly going on to more complex topics including the use of joins, subqueries, stored procedures, cursors, triggers, and table constraints. 
You'll learn methodically, systematically, and simply–in 22 short, quick lessons that will each take only 10 minutes or less to complete. 

With the Fourth Edition of this worldwide bestseller, the book has been thoroughly updated, expanded, and improved. Lessons now cover the latest versions of IBM DB2, Microsoft Access, Microsoft SQL Server, MySQL, Oracle, PostgreSQL, SQLite, MariaDB, and Apache Open Office Base. And new full-color SQL code listings help the beginner clearly see the elements and structure of the language.

10 minutes is all you need to learn how to...
  • Use the major SQL statements
  • Construct complex SQL statements using multiple clauses and operators
  • Retrieve, sort, and format database contents
  • Pinpoint the data you need using a variety of filtering techniques
  • Use aggregate functions to summarize data
  • Join two or more related tables
  • Insert, update, and delete data
  • Create and alter database tables
  • Work with views, stored procedures, and more

 



SQL: The Ultimate Guide From Beginner To Expert - Learn And Master SQL In No Time! (2016 Edition)

Become An SQL Expert In Few Easy Steps

Learn the most useful tips by following this easy handbook!
Are you looking for more ways on how to improve your SQL skill? Do you want to see your database in an organised fashion?
Well if you answered “yes”, then read on!
Structured Query Language or SQL is famously used to interact with database. You may be working at a hotel, bank, government, or any industry, SQL is certainly a necessity to run your daily operations!
SQL: The Ultimate Guide From Beginner To Expert – Learn And Master SQL In No Time! is a book that will introduce you to a computer language that has helped so many business owners and information technologists with daily reports and database management without the fear of crashing.
Here’s what you’ll find inside:
  • SQL Basics
  • SQL and Data
  • Data Functions (Aggregate, Rowset, and Ranking)
  • Scalar Functions
  • Basics of Building a Table Using SQL
  • Recommendations

 


SQL Cookbook Query Solutions and Techniques for Database Developers

You know the rudiments of the SQL query language, yet you feel you aren't taking full advantage of SQL's expressive power. You'd like to learn how to do more work with SQL inside the database before pushing data across the network to your applications. You'd like to take your SQL skills to the next level.
Let's face it, SQL is a deceptively simple language to learn, and many database developers never go far beyond the simple statement: SELECT columns FROM table WHERE conditions. But there is so much more you can do with the language. In the SQL Cookbook, experienced SQL developer Anthony Molinaro shares his favorite SQL techniques and features. You'll learn about:


  • Window functions, arguably the most significant enhancement to SQL in the past decade. If you're not using these, you're missing out
  • Powerful, database-specific features such as SQL Server's PIVOT and UNPIVOT operators, Oracle's MODEL clause, and PostgreSQL's very useful GENERATE_SERIES function
  • Pivoting rows into columns, reverse-pivoting columns into rows, using pivoting to facilitate inter-row calculations, and double-pivoting a result set
  • Bucketization, and why you should never use that term in Brooklyn.
  • How to create histograms, summarize data into buckets, perform aggregations over a moving range of values, generate running-totals and subtotals, and other advanced, data warehousing techniques
  • The technique of walking a string, which allows you to use SQL to parse through the characters, words, or delimited elements of a string
Written in O'Reilly's popular Problem/Solution/Discussion style, the SQL Cookbook is sure to please. Anthony's credo is: "When it comes down to it, we all go to work, we all have bills to pay, and we all want to go home at a reasonable time and enjoy what's still available of our days." The SQL Cookbook moves quickly from problem to solution, saving you time each step of the way.

 


Learning SQL

Updated for the latest database management systems -- including MySQL 6.0, Oracle 11g, and Microsoft's SQL Server 2008 -- this introductory guide will get you up and running with SQL quickly. Whether you need to write database applications, perform administrative tasks, or generate reports, Learning SQL, Second Edition, will help you easily master all the SQL fundamentals.
Each chapter presents a self-contained lesson on a key SQL concept or technique, with numerous illustrations and annotated examples. Exercises at the end of each chapter let you practice the skills you learn. With this book, you will:
  • Move quickly through SQL basics and learn several advanced features
  • Use SQL data statements to generate, manipulate, and retrieve data
  • Create database objects, such as tables, indexes, and constraints, using SQL schema statements
  • Learn how data sets interact with queries, and understand the importance of subqueries
  • Convert and manipulate data with SQL's built-in functions, and use conditional logic in data statements
Knowledge of SQL is a must for interacting with data. With Learning SQL, you'll quickly learn how to put the power and flexibility of this language to work.

 

Database

In computing, databases are sometimes classified according to their organizational approach. The most prevalent approach is the relational database, a tabular database in which data is defined so that it can be reorganized and accessed in a number of different ways. A distributed database is one that can be dispersed or replicated among different points in a network. An object-oriented programming database is one that is congruent with the data defined in object classes and subclasses.
Computer databases typically contain aggregations of data records or files, such as sales transactions, product catalogs and inventories, and customer profiles. Typically, a database manager provides users the capabilities of controlling read/write access, specifying report generation, and analyzing usage. Databases and database managers are prevalent in largemainframe systems, but are also present in smaller distributed workstation and mid-range systems such as the AS/400 and on personal computers. SQL (Structured Query Language) is a standard language for making interactive queries from and updating a database such as IBM's DB2, Microsoft's SQL Server, and database products from OracleSybase, and Computer Associates.