0% found this document useful (0 votes)
7 views

SQL BY Surya

SQL short
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

SQL BY Surya

SQL short
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

-*-SQL-*-

By: GANESH G SURYA

What is Database?
A data is a collection of facts or figures, or information that’s stored and
can be used by a computer or a program for calculation, reasoning or
discussion

A database is a collection of related data stored in format that can easily


be accessed. Databases are used for storing, maintaining and accessing
any sort of data.

or

Database is collection of data in format that can be easily accessed A


software application used to manage our DB is called as DBMS.

Eg. phone contacts

There are two type of Database management system

1. Relational or SQL databases


2. Non-Relational or NoSQL database
A relational database is type of data store organizing da into tables that are related
to one another, as per the name.

EMP DEPT. GRADE


ID
101 IT A+
102 HR B
102 IT B+

RDBMS have a predefined schema, meaning data resides in row(records) and columns
(attributes) with a defined structure.

Eg. MYSQL , ORACLE,

Non-Relational or NoSQL database in which data not store in tables

Eg. Mongo DB
What is SQL?
SQL stand for Structured Query Language

SQL is programming language used to interact with relation databases

It is use to perform CRUD operation:

Create

Read

Update

Delete

SEQUEL (Structure query language)

DATA TYPES IN SQL SERVER


Exact Numeric Data Type:

 BIGINT : integer values ranging from -9,223,372,036,854,775,808 to


9,223,372,036,854,775,807
 INT : integer value ranging from -2,147,483,648 to 2,147,483,647
 SMALLINT : : integer value ranging from -32,768 to 32,767
 TINYINT : integer value ranging from 0 to255
 BIT : Represents a single bit value 0,1,NULL
 DECIMAL(p,s) : Fixed precision and scale numeric values
 NUMERIC(p,s) : same as DECIMAL

Approximate Numeric Data Types:

 FLOAT : Floating-point number with a decimal precision.


 REAL : Floating-point numbers with a decimal precision of 7 digits

NON Numeric Data Types:


 CHAR : it store character of fix size. In this memory will be wested some time

R A M
pysical memory allocation

 VARCHAR : it store character but up to given length

R A M
pysical memory allocation

 BLOB : it store large binary object

Signed & Unsigned


(both are use only on numeric value eg. INT , FLOAT , DOUBLE , TININT etc)

TINYINT UNSIGNED (0 to 255)

Above syntax is for unsigned number which are greater than 0 or +ve number only

TINYINT SIGNED (-128 to 127)

Above syntax is use for signed number which store both value +ve or -ve

TABLE

A table is database object to store data .data in table organized in rows (left to
right)and columns(top to down)

A table can be created in database using the CREATE table statement.

Columns : it show structure/schema(design)

Rows : it show individual data

Constraints
In SQL server, a constraint is a rule that is applied to colum or group of columns in
table to ensure dat integrity and consistency.Here are some of the most common
types of constrains
To make new SQL file

Syntax to create new data base is


CREATE DATABASE <name of database>;

With using this syntax we can create new DATABASE which is not present previously.

Syntax to delete data base is


DROP DATABASE< name of database >;

With using this syntax we can Delete DATABASE which is exist allready.

Syntax to use data base


USE < name of database >;

To use created DATABASE we have to use above syntax

Syntax to create table


CREATE TABLE <name of table>(
<Coloumn-name1> datatype constraint,

<Coloumn-name2> datatype constraint,

);

Eg.

CREATE TABLE student(

Id INT PRIMARY KEY,

Name VARCHAR(50),

Age INT NOT NULL

);

This type of table is created. in which id , name , age are the different columes of the
table .

Syntax to insert value in table


INSERT INTO <name of table> VALUES ( <id>, <name>,<age>);

Eg.

INSERT INTO student VALUE(1,”GANESH”,19);

In above syntax one row is created inside student table which consist of id as 1 name
as GANESH and age as 19.

Syntax to Print table


SELECT * FROM <name of table>;

Eg.

SELECT * FROM student;

With using above syntax we can print table and the output is
Types of SQL Commands
DDL (Data Definition Language) :
DQL (Data Query Language) :
DML (Data Manipulation Language) :
DCL (Data Control Language) :
TCL (Transaction Control Language) :

You might also like