Mysql Introdution and Its Data Types
Mysql Introdution and Its Data Types
data types
BY
group 1
VidyaPrathit,Gurunath,A
mita,Preshita
• MySQL’s connectivity, speed, and security make it highly suited for accessing
databases on the internet.
• The name MySQL derives from the name of co-founder Michael Widenius's
daughter and SQL.
# What is SQL
CHARACTERISTICS :
• Declarative Language: SQL is a declarative language,
which means that you specify what you want to do with the
data (e.g., retrieve, insert, update, or delete).
• RDBMS: SQL Is primarily used with relational databases.
• Data Query and Manipulation: SQL allows users to retrieve, insert,
update, and delete data in a database.
CHARACTERSTICS
• Data Definition Language (DDL): SQL includes DDL statements for defining and
managing the structure of a database.
• Data Integrity: SQL supports data integrity through constraints, which enforce rules
on the data to maintain its accuracy and consistency.
• Structured Data: SQL primarily deals with structured data, where data is organized
into tables with predefined schemas.
• Data Types: SQL supports various data types.
Advantages of sql
• High speed
• Using the SQL queries, the user can quickly and efficiently retrieve a large amount of records
from a database.
• No coding needed
In the standard SQL, it is very easy to manage the database system. It doesn't require a substantial
amount of code to manage the database system.
• Well defined standards
Long established are used by the SQL databases that are being used by ISO and ANSI.
• Portability
SQL can be used in laptop, PCs, server and even some mobile phones.
• Interactive language
SQL is a domain language used to communicate with the database. It is also used to receive
answers to the complex questions in seconds.
• Multiple data view
Using the SQL language, the users can make different views of the database structure.
DIsadvantages
• Complex Interface –
SQL has a difficult interface that makes few users uncomfortable while dealing with the database.
• Cost
Some versions are costly and hence, programmers cannot access it.
• Partial Control
Due to hidden business rules, complete control is not given to the database.
• Limited Flexibility
• SQL databases are less flexible than NoSQL databases when it comes to handling unstructured or semi-
structured data, as they require data to be structured into tables and columns.
• Lack of Real-Time Analytics
• SQL databases are designed for batch processing and do not support real-time analytics, which can be a
disadvantage for applications that require real-time data processing.
• Limited Query Performance
• SQL databases may have limited query performance when dealing with large datasets, as queries may take
longer to process than in-memory databases.
SQL DATAtypes
DATA TYPE
Data type indicates the type of data value that an attribute can have. The data type of an
attribute decides the operations that can be performed on the data of that attribute.
1. Numeric – bit, tinyint, smallint, int, bigint, decimal, numeric, float, real
1. A Simple Definition
Data types in SQL help to define what types of data a particular column or variable
can hold.
2. Why are they important?
Data types help prevent errors and storage issues by ensuring that the right type of
data is stored in the right way.
• 3. How to choose the right type of DataThe right data type depends on the type of
data you are storing, the size of the data, and the operations you plan to perform on that
data.
Numeric Data Types
Numbers without a decimal point. Numbers with a decimal point. A more flexible version of DECIMAL.
e.g. 42, 1234 , etc. e.g. 3.14,22.45, etc. It can hold larger numbers with more
digits, but requires more space.
e.g. 1.23456789
Character and String Data Types
3. Text
Store large blocks of text data. E.g Name , Address.
Date/Time Data Types
DATE DATETIME
Stores a date. e.g. 2000-11-20 Stores a date and time. e.g. 2000-
11-20 23:59:59
TIMESTAMP INTERVAL
Automatically records the date and time a Stores an interval of time. e.g.
row is inserted or updated. e.g. 2022-10-11 INTERVAL '1 day 2 hours'
15:27:12 means one day and two hours.
Examples of using Data Types in SQL
QUERY DESCRIPTION
SELECT title, release_date FROM movies; Returns the title and release date of all movies in the
database.
INSERT INTO accounts (user_id, password) VALUES Adds a new user with a username and password to
('johndoe', 'mysecretpassword'); the accounts table
UPDATE customers SET credit_limit = 10000 WHERE Increases the credit limit of customer 42 to $10,000.
customer_id = 42;
DATe and time
DATE − A date in YYYY-MM-DD format, between 1000-01-01 and 9999-12-31. For example,
December 30th, 1973 would be stored as 1973-12-30.
DATETIME − A date and time combination in YYYY-MM-DD HH:MM:SS format, between
1000-01-01 00:00:00 and 9999-12-31 23:59:59. For example, 3:30 in the afternoon on December
30th, 1973 would be stored as 1973-12-30 15:30:00.
DATe and time