Lesson 01(introduction of SQL)

 Introduction of SQL

SQL(Structured Query Language) ये RDBMS(Relational Database Management System) Language; data को store करने के लिए काफी मददगार Language है |

SQL में data को manipulate और retrieve किया जाता है |

SQL ये open-source language है |

SQL में User द्वारा कुछ records create किये जाते है | इस records को कुछ clauses और expression का इस्तेमाल करके modify, update, delete किया जाता है |

SQL ये RDBMS data को अपने अन्दर store करता है |

SQL की queries को MySQL, SQL Server, PostGre SQL, MS Access, Oracle इन किसी भी databases में store किया जाता है |

 

History of SQL

SQL का अविष्कार 1970 के आसपास में IBM के Donald Chamberlin और Raymond Boyce ने किया था | जब SQL को बनाया गया था तब इसका नाम 'SEQUEL'(Structured English Query Language) रखा गया था | लेकिन 'SEQUEL' ये UK के aircraft company का नाम पहले से ही था | उसके बाद में 'SEQUEL' ये नाम बदलकर 'SQL' रखा गया |

What is RDBMS ?

RDBMS ये Relational DataBase Management System का संक्षिप्त रूप है |

MySQL, SQL Server, PostGre SQL, MS Access और Oracle ये सब database systems RDBMS के आधार पर बनाये गए है |

RDBMS data को tables, records और fields’ में structured किया जाता है |

RDBMS के database के tables में fields के rows/records होते है |

बहुत सारे RDBMS; SQL इस query language का इस्तेमाल करते है |

RDBMS ये कुछ operators’ का इस्तेमाल table के rows या data को manipulate करने के लिए किया जाता है |

RDBMS Table

RDBMS में databases होते है | उन हर database में एक या एक से ज्यादा tables होते है | इन tables में data को store किया जाता है |

Database Name : student_info

Table Name : Student

id

first_name

last_name

percentages

1

Ram

Raman

83.25

2

Shyam

Joshi

56.85

3

Madhulika

Tare

92.45

RDBMS Field

tables में data को store करने के लिए fields को set करना पड़ता है | निचे tables के fields दिए गए है |

id

first_name

last_name

percentages

 

SQL - SQL Syntax

Database, table और उनके rows और columns के data को manipulate करने के लिए syntax को समझना बहुत ही जरुरी होता है |

SQL में statement के शुरुआत पर select, create, insert, delete, update, alter या drop जैसे keywords का इस्तेमाल किया जाता है |

SQL में सभी keywords case-insensitive होते है For Example, SELECT, CREATE इत्यादी | लेकिन सामान्यतः सभी keywords को uppercase में ही लिखा जाता है |

SQL में हर statement के आखिर पर semi-colon(;) को दिया जाता है |

SQL - Data Types

SQL अलग-अलग Data Types रखता है जैसे कि, Numeric, Characters, Binary, date और time जैसे Data Types होते है |

जब SQL में table को create करना पड़ता है तब table के हर column के लिए उसका data type देना पड़ता है |

User अपने जरुरत के मुताबिक data type को चुन सकता है |

Data Tye in SQL

Numeric Data Types in SQL

Data Type

Syntax

Range

Integer

INT

-231 to +231-1(-2,14,74,83,648 to +2,14,74,83,647)

Small Integer

SMALLINT

-215 to +215-1(-32768 to +32767)

Big Integer

BIGINT

-263 to +263-1(92,23,37,20,36,85,47,75,808 to +92,23,37,20,36,85,47,75,807)

Tiny Integer

TINYINT

0 to +28-1(0 to 255)

Bit

BIT

0 or 1

Numeric(Precision, Scale)

NUMERIC(Precision, Scale)

-1038+1 to +1038-1(-1.e+38 to +1.e+38)

Decimal or Dec

DECIMAL(Precision, Scale) or

DEC(Precision, Scale)

-1038+1 to +1038-1(-1.e+38 to +1.e+38)

Float

FLOAT(Precision)

-1.79E+308 to +1.79E+308

Real

REAL

-3.40E + 38 to +3.40E + 38

  

Character Data Types

Data Type

Syntax

Range

Character String

CHAR

Maximum 8,000 characters

Character String

VARCHAR

Maximum 8,000 characters

Unicode Character String

NCHAR

Maximum 4,000 characters

Unicode Character String

NVARCHAR

Maximum 4,000 characters

Character String

TEXT

Maximum 231 = 2,147,483,647 characters

Unicode Character String

NTEXT

Maximum 230 = 1,073,741,823 characters

Binary Data Types

Data Type

Syntax

Range

Binary Value

BINARY

Maximum 8,000 Bytes

Binary Value

VARBINARY

Maximum 8,000 Bytes

Image

IMAGE

Maximum 231 = 2,147,483,647 Bytes

 



Date and Time Data Types

Data Type

Syntax

Example

date

DATE

For Example, Feb 27, 2015(Format : YYYY-MM-DD)

time

TIME

For Example, 2:15 A.M.(format : )

datetime

DATETIME

Range : January 1, 1753 to December 31, 9999(format : YYYY-MM-DD HH:MI:SS)

smalldatetime

SMALLDATETIME

Range : January 1, 1900 to June 6, 2079(format : YYYY-MM-DD HH:MI:SS)

timestamp

TIMESTAMP

format : YYYY-MM-DD HH:MI:SS (store year, month, day, hour, minute and second)

Comments

Popular posts from this blog

Lesson 07 (Primary Key & Foreign Key)

Lesson 03 (Filter Data)

Lesson 05(Modifying Data)