In today's video of mysql series we will be discussing about different datatypes in mysql
You can check the entire playlist from the above I button
So without any further delay let's get started with our today's topic
Mysql datatypes
The data type of a column defines what value the column can hold: integer, character, money, date and time, binary, and so on.
In MySQL there are three main data types: string, numeric, and date and time.
In today's video we will be discussing about string data type
CHAR(size)A FIXED length string (can contain letters, numbers, and special characters). The size parameter specifies the column length in characters - can be from 0 to 255. Default is 1
VARCHAR(size)A VARIABLE length string (can contain letters, numbers, and special characters). The size parameter specifies the maximum column length in characters - can be from 0 to 65535
So let's apply this with some examples
1 CHAR(n)
Syntax
Create table employee (
emp_id CHAR(5)
);
INSERT INTO employee VALUES('W1234');
It stores fixed length strings.If the values are shorter, it's padded with spaces
Good for codes where id length is constant
2NCHAR(n) It stores fixed length unicode characters(international texts)
N before the string means Unicode
Useful for multilingual databases
Create table Country (
CountryCode NCHAR(3)
);
INSERT INTO Country VALUES(N'IND');
DESC Country;
3 VARCHAR(n) It stores variable length strings up to N characters
Saves space if data length varies
Create table Student(
Name varchar(20)
);
Insert into student values ('Priya Agarwal');
Desc student;
4 NVARCHAR(n) It stores variable length unicode string Perfect for storing names in multiple language
Create table Product(
ProductName NVARCHAR(100)
);
INSERT INTO PRODUCT VALUES (N')
DESC Product;
That's it for today
We will discuss next datatypes of mysql in my upcoming video
#mysql
#mysqltutorial
#howtoinsertdataintotableinmysql
#insertdataintotableusingmysq
#insertdataintotableinmysql
#insertdataintotable
#mysqladddataintotable
#mysqlinsertdataintotable
#mysqlinsertquery
#mysqladdquery
#mysqlinsertquerywithexample
#mysqlinsert
#sqlinsertcommand
#mysqlinsertintocommand
#howtoinsertdataintableswithsql
#sqlbasics
#mysqlcourse
#mysqltutorialinhindi
#mysqldatabasetutorial
#mysqlcrashcourse
#datatypesinmysql
#datatypesinMySQL
#Mysqldatatype
#stringdatatype
#stringdatatypeinmysql
#stringdatatypeinsql
#mysqlstringdatatype