Presentation is loading. Please wait.

Presentation is loading. Please wait.

Structured Query Language Path from Unorganized to Organized….

Similar presentations


Presentation on theme: "Structured Query Language Path from Unorganized to Organized…."— Presentation transcript:

1 Structured Query Language Path from Unorganized to Organized….
SQL Structured Query Language Path from Unorganized to Organized…. © wideskills.com

2 What is a Database… A database is an organized collection of data. The database management system(DBMS) is the system which acts as medium to carry data from database and user. There are 4 types of DBMS Hierarchical DBMS Network DBMS Relational DBMS Object Oriented DBMS © wideskills.com

3 What is SQL… SQL is the standard used to manage data in relational tables. Structured Query Language normally referred as SQL and pronounced as SEE QU EL.. SQL allows users to create databases, add data, modify and maintain data. It is governed by standards maintained by ISO(International Standards Organization). Example of a relational table: Employee Department Emp Id Emp Name Age Dept_id 1 John 40 2 Linda 35 3 Max 30 Dept_id Dept_name 1 Accounts 2 Production © wideskills.com

4 SQL syntax and query SQL is case in-sensitive, that is keyword SELECT and select is same for SQL. Every SQL command should end with a semi-colon (;). If the syntax is not proper, then executing the command would result in syntax error. Command used to fetch data from table is called as query. A basic SQL query consists of SELECT, FROM and WHERE clause. SQL SELECT Command example: SELECT col1, col2, col3,….. FROM table_name WHERE condition; © wideskills.com

5 Datatypes in SQL Data type is the attribute of the data expected in the column. Depending upon the SQL implementation (version) different data types are available. Whenever you create a column using the data type, the SQL Implementation program would allocate appropriate amount of space to store the data. Data types are broadly categorized into Numerics, Strings, Binary, Datetime, Collection and XML. Most commonly used data types are Integer, Decimal, Float, Character, Varchar, Boolean, Date. Example: Boolean Value : Return value = “True” INT : 5400, -2500 Numeric or Decimal: Decimal(4,2) = © wideskills.com

6 Operators and expressions in SQL
In SQL, operators are used in an SQL statement’s WHERE clause to perform different operations like comparison, logical and arithmetic operations. Operators that can be used are logical, comparison and Arithmetic. The Operators include <,>,<>,AND,OR,BETWEEN,ISNULL,+,-,?,% etc. Generally in any programming language, expression is a combination of values, constants, variables, operators and functions that results in a value. In SQL, expressions are used to query database/table to get specific data. Syntax: SELECT cols|expressions FROM table_name WHERE condition(using operators|expressions); © wideskills.com

7 SQL commands can be used to create databases, edit data in tables, delete data and maintain data in tables. SQL commands are classified into 3 groups: DDL(Data definition Language), DML(Data Manipulation Language) and DCL(Data Control Language). DDL CREATE ALTER DROP CREATE INDEX DROP INDEX DML SELECT INSERT INTO UPDATE DELETE DCL GRANT REVOKE Let us start with CREATE… © wideskills.com

8 Create Database and Table
As part of the Data Definition Language (DDL) under SQL, CREATE keyword is used to create databases and tables. One would need to first create Database and then under that database create the required tables. Syntax for creation of database: CREATE DATABASE database_name; The SQL CREATE TABLE statement allows you to create and define tables in a database. Syntax for creation of table: CREATE TABLE tablename ( column1 datatype NULL/NOT NULL, Column2 datatype NULL/NOT NULL ………………… PRIMARY KEY (column name or names), FOREIGN KEY(column name) REFERENCES Tablename(column name) ); WE will learn about Primary and Foreign key in the constraints slide… Optional © wideskills.com

9 Create Database and Table-1
Example Create employee table, which has a constraint on Department id of Departments table(i.e. value of department id in employee table depends on the value of Department id in Departments table). CREATE TABLE employee( Emp_ID INT NOT NULL, Emp_Name Varchar(20) NOT NULL, AGE INT NOT NULL, Phone_Num INT, Dept_ID INT NOT NULL, PRIMARY KEY(Emp_ID), FOREIGN KEY(DEPT_ID) REFERENCES DEPARTMENTS(DEPT_ID)); © wideskills.com

10 Interesting, right? This is just a sneak preview of the full presentation. We hope you like it! To see the rest of it, just click here to view it in full on PowerShow.com. Then, if you’d like, you can also log in to PowerShow.com to download the entire presentation for free.


Download ppt "Structured Query Language Path from Unorganized to Organized…."

Similar presentations


Ads by Google