postgresqlHow do I use the PostgreSQL VARCHAR data type?
The PostgreSQL VARCHAR
data type is used to store character strings of variable length. It is similar to CHAR
except that it stores strings of variable length up to a maximum of n
characters, where n
is the specified length of the column.
For example, to create a VARCHAR
column with a maximum length of 10 characters:
CREATE TABLE products (
product_name VARCHAR(10)
);
The parts of this code are:
CREATE TABLE
: the SQL command used to create a new tableproducts
: the name of the new tableproduct_name
: the name of the columnVARCHAR(10)
: the data type and maximum length of the column
When inserting data into the product_name
column, the value must not exceed 10 characters.
For more information, please refer to the PostgreSQL documentation.
More of Postgresql
- How can I set a PostgreSQL interval to zero?
- How can I troubleshoot zero damaged pages in PostgreSQL?
- How do I use PostgreSQL ZonedDateTime to store date and time information?
- How can I use PostgreSQL and ZFS snapshots together?
- How can I use PostgreSQL's "zero if null" feature?
- How do I use PostgreSQL and ZFS together?
- How do I use PostgreSQL's XMLTABLE to parse XML data?
- How can I monitor PostgreSQL performance using Zabbix?
- How can I use PostgreSQL with Zabbix?
- How can I extract the year from a PostgreSQL timestamp?
See more codes...