Translate

Friday 1 October 2021

SQL group by avg and sum sql videos in telugu 41

https://youtu.be/frR9NE-9mPE ------------------------------------------
CHAR and VARCHAR are both ASCII character data types and almost same but they are different at the stage of storing and retrieving the data from the database.


CHAR Data Type
VARCHAR Data Type
Its full name is CHARACTER

Its full name is VARIABLE CHARACTER

It stores values in fixed lengths and are padded with space characters to match the specified length

VARCHAR stores values in variable length along with 1-byte or 2-byte length prefix and are not padded with any characters

It can hold a maximum of 255 characters.
It can hold a maximum of 65,535 characters.

It uses static memory allocation.
mysql>create table vlr(name CHAR(20));
Query OK, 0 rows affected (0.25
It uses dynamic memory allocation.
mysql>create table vlr1(name VARCHAR(20));
Query OK, 0 rows affected (0.21


Mounika@MOUNIKA-PC c:\xampp
# ram.cmd
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 9
Server version: 10.4.18-MariaDB mariadb.org binary distribution

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> use vlrinst;
Database changed
MariaDB [vlrinst]> create table vlr(name char(5));
Query OK, 0 rows affected (0.215 sec)

MariaDB [vlrinst]> create table vlr1(name varchar(5));
Query OK, 0 rows affected (0.209 sec)

MariaDB [vlrinst]> insert into vlr values("ramesh");
Query OK, 1 row affected, 1 warning (0.069 sec)

MariaDB [vlrinst]> select * from vlr;
+-------+
| name  |
+-------+
| rames |
+-------+
1 row in set (0.001 sec)

MariaDB [vlrinst]> insert into vlr values("ram");
Query OK, 1 row affected (0.088 sec)

MariaDB [vlrinst]> select * from vlr;
+-------+
| name  |
+-------+
| rames |
| ram   |
+-------+
2 rows in set (0.000 sec)

MariaDB [vlrinst]> insert into vlr1 values("ramesh");
Query OK, 1 row affected, 1 warning (0.056 sec)

MariaDB [vlrinst]> select * from vlr1;
+-------+
| name  |
+-------+
| rames |
+-------+
1 row in set (0.000 sec)

MariaDB [vlrinst]> create table vlr2(name varchar(3000));
Query OK, 0 rows affected (0.290 sec)

MariaDB [vlrinst]> create table vlr3(name char(3000));
ERROR 1074 (42000): Column length too big for column 'name' (max = 255); use BLOB or TEXT instead
MariaDB [vlrinst]> create table vlr3(name char(255));
Query OK, 0 rows affected (0.195 sec)

MariaDB [vlrinst]>

No comments:

Post a Comment

Note: only a member of this blog may post a comment.