Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0937f6d

Browse files
committed
Doc: document bpchar, clarify relationship of text and varchar.
For some reason the "bpchar" type name was defined nowhere inour SGML docs, although several places refer to it in passing.Give it a proper mention under Character Types.While here, also provide an explanation of how the text and varchartypes relate. The previous wording seemed to be doing its bestto sweep text under the rug, which doesn't seem very appropriategiven its prominence in other parts of the docs.Minor rearrangements and word-smithing for clarity, too.Laurenz Albe and Tom Lane, per gripe from Yanliang LeiDiscussion:https://postgr.es/m/120b3084.56b6.1833b5ffe4b.Coremail.msdnchina@163.com
1 parent4d2a844 commit0937f6d

File tree

1 file changed

+36
-23
lines changed

1 file changed

+36
-23
lines changed

‎doc/src/sgml/datatype.sgml

Lines changed: 36 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1154,6 +1154,10 @@ SELECT '52093.89'::money::numeric::float8;
11541154
<primary>varchar</primary>
11551155
</indexterm>
11561156

1157+
<indexterm zone="datatype-character">
1158+
<primary>bpchar</primary>
1159+
</indexterm>
1160+
11571161
<table id="datatype-character-table">
11581162
<title>Character Types</title>
11591163
<tgroup cols="2">
@@ -1169,7 +1173,7 @@ SELECT '52093.89'::money::numeric::float8;
11691173
<entry>variable-length with limit</entry>
11701174
</row>
11711175
<row>
1172-
<entry><type>character(<replaceable>n</replaceable>)</type>, <type>char(<replaceable>n</replaceable>)</type></entry>
1176+
<entry><type>character(<replaceable>n</replaceable>)</type>, <type>char(<replaceable>n</replaceable>)</type>, <type>bpchar(<replaceable>n</replaceable>)</type></entry>
11731177
<entry>fixed-length, blank padded</entry>
11741178
</row>
11751179
<row>
@@ -1196,41 +1200,50 @@ SELECT '52093.89'::money::numeric::float8;
11961200
error, unless the excess characters are all spaces, in which case
11971201
the string will be truncated to the maximum length. (This somewhat
11981202
bizarre exception is required by the <acronym>SQL</acronym>
1199-
standard.) If the string to be stored is shorter than the declared
1203+
standard.)
1204+
However, if one explicitly casts a value to <type>character
1205+
varying(<replaceable>n</replaceable>)</type> or
1206+
<type>character(<replaceable>n</replaceable>)</type>, then an over-length
1207+
value will be truncated to <replaceable>n</replaceable> characters without
1208+
raising an error. (This too is required by the
1209+
<acronym>SQL</acronym> standard.)
1210+
If the string to be stored is shorter than the declared
12001211
length, values of type <type>character</type> will be space-padded;
12011212
values of type <type>character varying</type> will simply store the
12021213
shorter
12031214
string.
12041215
</para>
12051216

12061217
<para>
1207-
If one explicitly casts a value to <type>character
1208-
varying(<replaceable>n</replaceable>)</type> or
1209-
<type>character(<replaceable>n</replaceable>)</type>, then an over-length
1210-
value will be truncated to <replaceable>n</replaceable> characters without
1211-
raising an error. (This too is required by the
1212-
<acronym>SQL</acronym> standard.)
1218+
In addition, <productname>PostgreSQL</productname> provides the
1219+
<type>text</type> type, which stores strings of any length.
1220+
Although the <type>text</type> type is not in the
1221+
<acronym>SQL</acronym> standard, several other SQL database
1222+
management systems have it as well.
1223+
<type>text</type> is <productname>PostgreSQL</productname>'s native
1224+
string data type, in that most built-in functions operating on strings
1225+
are declared to take or return <type>text</type> not <type>character
1226+
varying</type>. For many purposes, <type>character varying</type>
1227+
acts as though it were a <link linkend="domains">domain</link>
1228+
over <type>text</type>.
12131229
</para>
12141230

12151231
<para>
1216-
The notations <type>varchar(<replaceable>n</replaceable>)</type> and
1217-
<type>char(<replaceable>n</replaceable>)</type> are aliases for <type>character
1218-
varying(<replaceable>n</replaceable>)</type> and
1219-
<type>character(<replaceable>n</replaceable>)</type>, respectively.
1220-
If specified, the length must be greater than zero and cannot exceed
1221-
10485760.
1222-
<type>character</type> without length specifier is equivalent to
1223-
<type>character(1)</type>. If <type>character varying</type> is used
1224-
without length specifier, the type accepts strings of any size. The
1225-
latter is a <productname>PostgreSQL</productname> extension.
1232+
The type name <type>varchar</type> is an alias for <type>character
1233+
varying</type>, while <type>char</type> and <type>bpchar</type> are
1234+
aliases for <type>character</type>.
1235+
The <type>varchar</type> and <type>char</type> aliases are defined in
1236+
the <acronym>SQL</acronym> standard, but <type>bpchar</type> is
1237+
a <productname>PostgreSQL</productname> extension.
12261238
</para>
12271239

12281240
<para>
1229-
In addition, <productname>PostgreSQL</productname> provides the
1230-
<type>text</type> type, which stores strings of any length.
1231-
Although the type <type>text</type> is not in the
1232-
<acronym>SQL</acronym> standard, several other SQL database
1233-
management systems have it as well.
1241+
If specified, the length <replaceable>n</replaceable> must be greater
1242+
than zero and cannot exceed 10485760.
1243+
<type>character</type> without length specifier is equivalent to
1244+
<type>character(1)</type>. If <type>character varying</type> is used
1245+
without length specifier, the type accepts strings of any size. The
1246+
latter behavior is a <productname>PostgreSQL</productname> extension.
12341247
</para>
12351248

12361249
<para>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp