mysql longtext code example

Example 1: mysql text type max length

Type       | Approx. Length     | Exact Max. Length Allowed
-----------------------------------------------------------
TINYTEXT   | 256 Bytes          |           255 characters
TEXT       |  64 Kilobytes      |        65,535 characters
MEDIUMTEXT |  16 Megabytes      |    16,777,215 characters
LONGTEXT   |   4 Gigabytes      | 4,294,967,295 characters

Example 2: mysql vs postgresql

/*Postgres is an object-relational database, while MySQL is a purely 
relational database. This means that Postgres includes features like
table inheritance and function overloading, which can be important
to certain applications. Postgres also adheres more closely to SQL
standards.

Postgres handles concurrency better than MySQL for multiple reasons:

Postgres implements Multiversion Concurrency Control (MVCC) without 
read locks Postgres supports parallel query plans that can use multiple
CPUs/cores Postgres can create indexes in a non-blocking way (through 
the CREATE INDEX CONCURRENTLY syntax), and it can create partial
indexes (for example, if you have a model with soft deletes, you
can create an index that ignores records marked as deleted) 
Postgres is known for protecting data integrity at the transaction 
level. This makes it less vulnerable to data corruption.*/

Example 3: postgresql gset

=> SELECT 'hello' AS var1, 10 AS var2
-> \gset
=> \echo :var1 :var2
hello 10

Tags:

Sql Example