CREATE FUNCTION
Syntax
1021
create_specification
options specify database characteristics. Database characteristics are
stored in the
db.opt
file in the database directory. The
CHARACTER SET
clause specifies the default
database character set. The
COLLATE
clause specifies the default database collation.
Section 10.1,
“Character Set Support”
, discusses character set and collation names.
A database in MySQL is implemented as a directory containing files that correspond to tables in
the database. Because there are no tables in a database when it is initially created, the
CREATE
DATABASE
statement creates only a directory under the MySQL data directory and the
db.opt
file.
Rules for permissible database names are given in
Section 9.2, “Schema Object Names”
.
If you manually create a directory under the data directory (for example, with
mkdir
), the server
considers it a database directory and it shows up in the output of
SHOW DATABASES
.
You can also use the
mysqladmin
program to create databases. See
Section 4.5.2, “
mysqladmin
—
Client for Administering a MySQL Server”
.
13.1.7.
CREATE FUNCTION
Syntax
The
CREATE FUNCTION
statement is used to create stored functions and user-defined functions
(UDFs):
• For information about creating stored functions, see
Section 13.1.9, “
CREATE PROCEDURE
and
CREATE FUNCTION
Syntax”
.
• For information about creating user-defined functions, see
Section 13.7.3.1, “
CREATE FUNCTION
Syntax for User-defined Functions”
.
13.1.8.
CREATE INDEX
Syntax
CREATE [UNIQUE|FULLTEXT|SPATIAL] INDEX
index_name
[
index_type
]
ON
tbl_name
(
index_col_name
,...)
[
index_type
]
index_col_name
:
col_name
[(
length
)] [ASC | DESC]
index_type
:
USING {BTREE | HASH}
CREATE INDEX
is mapped to an
ALTER TABLE
statement to create indexes. See
Section 13.1.4,
“
ALTER TABLE
Syntax”
.
CREATE INDEX
cannot be used to create a
PRIMARY KEY
; use
ALTER
TABLE
instead. For more information about indexes, see
Section 8.5.3, “How MySQL Uses Indexes”
.
Normally, you create all indexes on a table at the time the table itself is created with
CREATE TABLE
.
See
Section 13.1.10, “
CREATE TABLE
Syntax”
.
CREATE INDEX
enables you to add indexes to
existing tables.
A column list of the form
(col1,col2,...)
creates a multiple-column index. Index values are formed
by concatenating the values of the given columns.
Indexes can be created that use only the leading part of column values, using
col_name(length)
syntax to specify an index prefix length:
• Prefixes can be specified for
CHAR
,
VARCHAR
,
BINARY
, and
VARBINARY
columns.
•
BLOB
and
TEXT
columns also can be indexed, but a prefix length must be given.
• Prefix lengths are given in characters for nonbinary string types and in bytes for binary string
types. That is, index entries consist of the first
length
characters of each column value for
CHAR
,
VARCHAR
, and
TEXT
columns, and the first
length
bytes of each column value for
BINARY
,
VARBINARY
, and
BLOB
columns.
• For spatial columns, prefix values can be given as described later in this section.
Содержание 5.0
Страница 1: ...MySQL 5 0 Reference Manual ...
Страница 18: ...xviii ...
Страница 60: ...40 ...
Страница 396: ...376 ...
Страница 578: ...558 ...
Страница 636: ...616 ...
Страница 844: ...824 ...
Страница 1234: ...1214 ...
Страница 1426: ...MySQL Proxy Scripting 1406 The following diagram shows an overview of the classes exposed by MySQL Proxy ...
Страница 1427: ...MySQL Proxy Scripting 1407 ...
Страница 1734: ...1714 ...
Страница 1752: ...1732 ...
Страница 1783: ...Configuring Connector ODBC 1763 ...
Страница 1793: ...Connector ODBC Examples 1773 ...
Страница 1839: ...Connector Net Installation 1819 2 You must choose the type of installation to perform ...
Страница 1842: ...Connector Net Installation 1822 5 Once the installation has been completed click Finish to exit the installer ...
Страница 1864: ...Connector Net Visual Studio Integration 1844 Figure 20 24 Debug Stepping Figure 20 25 Function Stepping 1 of 2 ...
Страница 2850: ...2830 ...
Страница 2854: ...2834 ...
Страница 2928: ...2908 ...
Страница 3000: ...2980 ...
Страница 3122: ...3102 ...
Страница 3126: ...3106 ...
Страница 3174: ...3154 ...
Страница 3232: ...3212 ...