Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
49a188f7
Commit
49a188f7
authored
Apr 20, 2002
by
paul@teton.kitebird.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
manual.texi More keyword capping.
parent
665a0909
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
63 additions
and
62 deletions
+63
-62
Docs/manual.texi
Docs/manual.texi
+63
-62
No files found.
Docs/manual.texi
View file @
49a188f7
...
@@ -32415,7 +32415,7 @@ mysql> SELECT BIT_COUNT(29);
...
@@ -32415,7 +32415,7 @@ mysql> SELECT BIT_COUNT(29);
Returns the current database name:
Returns the current database name:
@example
@example
mysql>
select
DATABASE();
mysql>
SELECT
DATABASE();
-> 'test'
-> 'test'
@end example
@end example
...
@@ -32430,7 +32430,7 @@ If there is no current database, @code{DATABASE()} returns the empty string.
...
@@ -32430,7 +32430,7 @@ If there is no current database, @code{DATABASE()} returns the empty string.
Returns the current MySQL user name:
Returns the current MySQL user name:
@example
@example
mysql>
select
USER();
mysql>
SELECT
USER();
-> 'davida@@localhost'
-> 'davida@@localhost'
@end example
@end example
...
@@ -32439,7 +32439,7 @@ as well as the user name. You can extract just the user name part like this
...
@@ -32439,7 +32439,7 @@ as well as the user name. You can extract just the user name part like this
(which works whether or not the value includes a hostname part):
(which works whether or not the value includes a hostname part):
@example
@example
mysql>
select substring_index
(USER(),"@@",1);
mysql>
SELECT SUBSTRING_INDEX
(USER(),"@@",1);
-> 'davida'
-> 'davida'
@end example
@end example
...
@@ -32450,7 +32450,7 @@ the function that is used for encrypting MySQL passwords for storage
...
@@ -32450,7 +32450,7 @@ the function that is used for encrypting MySQL passwords for storage
in the @code{Password} column of the @code{user} grant table:
in the @code{Password} column of the @code{user} grant table:
@example
@example
mysql>
select
PASSWORD('badpwd');
mysql>
SELECT
PASSWORD('badpwd');
-> '7f84554057dd964b'
-> '7f84554057dd964b'
@end example
@end example
...
@@ -32470,7 +32470,7 @@ Encrypt @code{str} using the Unix @code{crypt()} system call. The
...
@@ -32470,7 +32470,7 @@ Encrypt @code{str} using the Unix @code{crypt()} system call. The
(As of MySQL Version 3.22.16, @code{salt} may be longer than two characters.):
(As of MySQL Version 3.22.16, @code{salt} may be longer than two characters.):
@example
@example
mysql>
select
ENCRYPT("hello");
mysql>
SELECT
ENCRYPT("hello");
-> 'VxuFAJXVARROc'
-> 'VxuFAJXVARROc'
@end example
@end example
...
@@ -32501,7 +32501,7 @@ Calculates a MD5 checksum for the string. Value is returned as a 32 long
...
@@ -32501,7 +32501,7 @@ Calculates a MD5 checksum for the string. Value is returned as a 32 long
hex number that may, for example, be used as a hash key:
hex number that may, for example, be used as a hash key:
@example
@example
mysql>
select
MD5("testing");
mysql>
SELECT
MD5("testing");
-> 'ae2b1fca515949e5d54fb22b8ed95575'
-> 'ae2b1fca515949e5d54fb22b8ed95575'
@end example
@end example
...
@@ -32594,7 +32594,7 @@ Returns the last automatically generated value that was inserted into an
...
@@ -32594,7 +32594,7 @@ Returns the last automatically generated value that was inserted into an
@xref{mysql_insert_id,, @code{mysql_insert_id()}}.
@xref{mysql_insert_id,, @code{mysql_insert_id()}}.
@example
@example
mysql>
select
LAST_INSERT_ID();
mysql>
SELECT
LAST_INSERT_ID();
-> 195
-> 195
@end example
@end example
...
@@ -32617,14 +32617,14 @@ auto_increment value. This can be used to simulate sequences:
...
@@ -32617,14 +32617,14 @@ auto_increment value. This can be used to simulate sequences:
First create the table:
First create the table:
@example
@example
mysql>
create table sequence (id int not null
);
mysql>
CREATE TABLE sequence (id INT NOT NULL
);
mysql>
insert into sequence values
(0);
mysql>
INSERT INTO sequence VALUES
(0);
@end example
@end example
Then the table can be used to generate sequence numbers like this:
Then the table can be used to generate sequence numbers like this:
@example
@example
mysql>
update sequence set
id=LAST_INSERT_ID(id+1);
mysql>
UPDATE sequence SET
id=LAST_INSERT_ID(id+1);
@end example
@end example
You can generate sequences without calling @code{LAST_INSERT_ID()}, but the
You can generate sequences without calling @code{LAST_INSERT_ID()}, but the
...
@@ -32648,11 +32648,11 @@ to @code{D} decimals. If @code{D} is @code{0}, the result will have no
...
@@ -32648,11 +32648,11 @@ to @code{D} decimals. If @code{D} is @code{0}, the result will have no
decimal point or fractional part:
decimal point or fractional part:
@example
@example
mysql>
select
FORMAT(12332.123456, 4);
mysql>
SELECT
FORMAT(12332.123456, 4);
-> '12,332.1235'
-> '12,332.1235'
mysql>
select
FORMAT(12332.1,4);
mysql>
SELECT
FORMAT(12332.1,4);
-> '12,332.1000'
-> '12,332.1000'
mysql>
select
FORMAT(12332.2,0);
mysql>
SELECT
FORMAT(12332.2,0);
-> '12,332'
-> '12,332'
@end example
@end example
...
@@ -32661,7 +32661,7 @@ mysql> select FORMAT(12332.2,0);
...
@@ -32661,7 +32661,7 @@ mysql> select FORMAT(12332.2,0);
Returns a string indicating the MySQL server version:
Returns a string indicating the MySQL server version:
@example
@example
mysql>
select
VERSION();
mysql>
SELECT
VERSION();
-> '3.23.13-log'
-> '3.23.13-log'
@end example
@end example
...
@@ -32674,7 +32674,7 @@ Returns the connection id (@code{thread_id}) for the connection.
...
@@ -32674,7 +32674,7 @@ Returns the connection id (@code{thread_id}) for the connection.
Every connection has its own unique id:
Every connection has its own unique id:
@example
@example
mysql>
select
CONNECTION_ID();
mysql>
SELECT
CONNECTION_ID();
-> 1
-> 1
@end example
@end example
...
@@ -32693,13 +32693,13 @@ the same name; clients that agree on a given lock string name can use the
...
@@ -32693,13 +32693,13 @@ the same name; clients that agree on a given lock string name can use the
string to perform cooperative advisory locking:
string to perform cooperative advisory locking:
@example
@example
mysql>
select
GET_LOCK("lock1",10);
mysql>
SELECT
GET_LOCK("lock1",10);
-> 1
-> 1
mysql>
select
GET_LOCK("lock2",10);
mysql>
SELECT
GET_LOCK("lock2",10);
-> 1
-> 1
mysql>
select
RELEASE_LOCK("lock2");
mysql>
SELECT
RELEASE_LOCK("lock2");
-> 1
-> 1
mysql>
select
RELEASE_LOCK("lock1");
mysql>
SELECT
RELEASE_LOCK("lock1");
-> NULL
-> NULL
@end example
@end example
...
@@ -32727,7 +32727,7 @@ processes the expression. The result value is always @code{0}. The intended
...
@@ -32727,7 +32727,7 @@ processes the expression. The result value is always @code{0}. The intended
use is in the @code{mysql} client, which reports query execution times:
use is in the @code{mysql} client, which reports query execution times:
@example
@example
mysql>
select BENCHMARK(1000000,encode
("hello","goodbye"));
mysql>
SELECT BENCHMARK(1000000,ENCODE
("hello","goodbye"));
+----------------------------------------------+
+----------------------------------------------+
| BENCHMARK(1000000,encode("hello","goodbye")) |
| BENCHMARK(1000000,encode("hello","goodbye")) |
+----------------------------------------------+
+----------------------------------------------+
...
@@ -32747,7 +32747,7 @@ Given a numeric network address (4 or 8 byte), returns the dotted-quad
...
@@ -32747,7 +32747,7 @@ Given a numeric network address (4 or 8 byte), returns the dotted-quad
representation of the address as a string:
representation of the address as a string:
@example
@example
mysql>
select
INET_NTOA(3520061480);
mysql>
SELECT
INET_NTOA(3520061480);
-> "209.207.224.40"
-> "209.207.224.40"
@end example
@end example
...
@@ -32758,7 +32758,7 @@ returns an integer that represents the numeric value of the address.
...
@@ -32758,7 +32758,7 @@ returns an integer that represents the numeric value of the address.
Addresses may be 4 or 8 byte addresses:
Addresses may be 4 or 8 byte addresses:
@example
@example
mysql>
select
INET_ATON("209.207.224.40");
mysql>
SELECT
INET_ATON("209.207.224.40");
-> 3520061480
-> 3520061480
@end example
@end example
...
@@ -32784,7 +32784,7 @@ Returns the number of rows that the last @code{SELECT SQL_CALC_FOUND_ROWS ...}
...
@@ -32784,7 +32784,7 @@ Returns the number of rows that the last @code{SELECT SQL_CALC_FOUND_ROWS ...}
command would have returned, if wasn't restricted with @code{LIMIT}.
command would have returned, if wasn't restricted with @code{LIMIT}.
@example
@example
mysql> SELECT SQL_CALC_FOUND_ROWS * FROM t
able
_name
mysql> SELECT SQL_CALC_FOUND_ROWS * FROM t
bl
_name
WHERE id > 100 LIMIT 10;
WHERE id > 100 LIMIT 10;
mysql> SELECT FOUND_ROWS();
mysql> SELECT FOUND_ROWS();
@end example
@end example
...
@@ -32833,7 +32833,7 @@ other columns are retrieved, and there is no @code{WHERE} clause.
...
@@ -32833,7 +32833,7 @@ other columns are retrieved, and there is no @code{WHERE} clause.
For example:
For example:
@example
@example
mysql>
select COUNT(*) from
student;
mysql>
SELECT COUNT(*) FROM
student;
@end example
@end example
@findex COUNT(DISTINCT)
@findex COUNT(DISTINCT)
...
@@ -32842,7 +32842,7 @@ mysql> select COUNT(*) from student;
...
@@ -32842,7 +32842,7 @@ mysql> select COUNT(*) from student;
Returns a count of the number of different non-@code{NULL} values:
Returns a count of the number of different non-@code{NULL} values:
@example
@example
mysql>
select COUNT(DISTINCT results) from
student;
mysql>
SELECT COUNT(DISTINCT results) FROM
student;
@end example
@end example
In MySQL you can get the number of distinct expression
In MySQL you can get the number of distinct expression
...
@@ -32855,8 +32855,8 @@ inside @code{CODE(DISTINCT ...)}.
...
@@ -32855,8 +32855,8 @@ inside @code{CODE(DISTINCT ...)}.
Returns the average value of @code{expr}:
Returns the average value of @code{expr}:
@example
@example
mysql>
select
student_name, AVG(test_score)
mysql>
SELECT
student_name, AVG(test_score)
->
from
student
->
FROM
student
-> GROUP BY student_name;
-> GROUP BY student_name;
@end example
@end example
...
@@ -32869,8 +32869,8 @@ Returns the minimum or maximum value of @code{expr}. @code{MIN()} and
...
@@ -32869,8 +32869,8 @@ Returns the minimum or maximum value of @code{expr}. @code{MIN()} and
minimum or maximum string value. @xref{MySQL indexes}.
minimum or maximum string value. @xref{MySQL indexes}.
@example
@example
mysql>
select
student_name, MIN(test_score), MAX(test_score)
mysql>
SELECT
student_name, MIN(test_score), MAX(test_score)
->
from
student
->
FROM
student
-> GROUP BY student_name;
-> GROUP BY student_name;
@end example
@end example
...
@@ -32909,9 +32909,9 @@ grouping on unnecessary items. For example, you don't need to group on
...
@@ -32909,9 +32909,9 @@ grouping on unnecessary items. For example, you don't need to group on
@code{customer.name} in the following query:
@code{customer.name} in the following query:
@example
@example
mysql>
select
order.custid,customer.name,max(payments)
mysql>
SELECT
order.custid,customer.name,max(payments)
->
from
order,customer
->
FROM
order,customer
->
where
order.custid = customer.custid
->
WHERE
order.custid = customer.custid
-> GROUP BY order.custid;
-> GROUP BY order.custid;
@end example
@end example
...
@@ -33023,8 +33023,8 @@ is used as the expression's column name and can be used with
...
@@ -33023,8 +33023,8 @@ is used as the expression's column name and can be used with
@code{ORDER BY} or @code{HAVING} clauses. For example:
@code{ORDER BY} or @code{HAVING} clauses. For example:
@example
@example
mysql>
select concat
(last_name,', ',first_name) AS full_name
mysql>
SELECT CONCAT
(last_name,', ',first_name) AS full_name
from
mytable ORDER BY full_name;
FROM
mytable ORDER BY full_name;
@end example
@end example
@item
@item
...
@@ -33070,10 +33070,10 @@ forms.
...
@@ -33070,10 +33070,10 @@ forms.
A table reference may be aliased using @code{tbl_name [AS] alias_name}:
A table reference may be aliased using @code{tbl_name [AS] alias_name}:
@example
@example
mysql>
select t1.name, t2.salary from
employee AS t1, info AS t2
mysql>
SELECT t1.name, t2.salary FROM
employee AS t1, info AS t2
->
where
t1.name = t2.name;
->
WHERE
t1.name = t2.name;
mysql>
select t1.name, t2.salary from
employee t1, info t2
mysql>
SELECT t1.name, t2.salary FROM
employee t1, info t2
->
where
t1.name = t2.name;
->
WHERE
t1.name = t2.name;
@end example
@end example
@item
@item
...
@@ -33082,11 +33082,11 @@ Columns selected for output may be referred to in @code{ORDER BY} and
...
@@ -33082,11 +33082,11 @@ Columns selected for output may be referred to in @code{ORDER BY} and
positions. Column positions begin with 1:
positions. Column positions begin with 1:
@example
@example
mysql>
select college, region, seed from
tournament
mysql>
SELECT college, region, seed FROM
tournament
-> ORDER BY region, seed;
-> ORDER BY region, seed;
mysql>
select college, region AS r, seed AS s from
tournament
mysql>
SELECT college, region AS r, seed AS s FROM
tournament
-> ORDER BY r, s;
-> ORDER BY r, s;
mysql>
select college, region, seed from
tournament
mysql>
SELECT college, region, seed FROM
tournament
-> ORDER BY 2, 3;
-> ORDER BY 2, 3;
@end example
@end example
...
@@ -33106,26 +33106,26 @@ the client, with no optimisation. Don't use @code{HAVING} for items that
...
@@ -33106,26 +33106,26 @@ the client, with no optimisation. Don't use @code{HAVING} for items that
should be in the @code{WHERE} clause. For example, do not write this:
should be in the @code{WHERE} clause. For example, do not write this:
@example
@example
mysql>
select col_name from
tbl_name HAVING col_name > 0;
mysql>
SELECT col_name FROM
tbl_name HAVING col_name > 0;
@end example
@end example
Write this instead:
Write this instead:
@example
@example
mysql>
select col_name from
tbl_name WHERE col_name > 0;
mysql>
SELECT col_name FROM
tbl_name WHERE col_name > 0;
@end example
@end example
In MySQL Version 3.22.5 or later, you can also write queries like this:
In MySQL Version 3.22.5 or later, you can also write queries like this:
@example
@example
mysql>
select user,max(salary) from
users
mysql>
SELECT user,MAX(salary) FROM
users
-> group by user HAVING max(salary)>10;
-> group by user HAVING max(salary)>10;
@end example
@end example
In older MySQL versions, you can write this instead:
In older MySQL versions, you can write this instead:
@example
@example
mysql>
select user,max(salary) AS sum from
users
mysql>
SELECT user,MAX(salary) AS sum FROM
users
-> group by user HAVING sum>10;
-> group by user HAVING sum>10;
@end example
@end example
...
@@ -33230,13 +33230,13 @@ return, the second specifies the maximum number of rows to return.
...
@@ -33230,13 +33230,13 @@ return, the second specifies the maximum number of rows to return.
The offset of the initial row is 0 (not 1):
The offset of the initial row is 0 (not 1):
@example
@example
mysql>
select * from
table LIMIT 5,10; # Retrieve rows 6-15
mysql>
SELECT * FROM
table LIMIT 5,10; # Retrieve rows 6-15
@end example
@end example
If one argument is given, it indicates the maximum number of rows to return:
If one argument is given, it indicates the maximum number of rows to return:
@example
@example
mysql>
select * from
table LIMIT 5; # Retrieve first 5 rows
mysql>
SELECT * FROM
table LIMIT 5; # Retrieve first 5 rows
@end example
@end example
In other words, @code{LIMIT n} is equivalent to @code{LIMIT 0,n}.
In other words, @code{LIMIT n} is equivalent to @code{LIMIT 0,n}.
...
@@ -33382,8 +33382,8 @@ A table reference may be aliased using @code{tbl_name AS alias_name} or
...
@@ -33382,8 +33382,8 @@ A table reference may be aliased using @code{tbl_name AS alias_name} or
@code{tbl_name alias_name}:
@code{tbl_name alias_name}:
@example
@example
mysql>
select t1.name, t2.salary from
employee AS t1, info AS t2
mysql>
SELECT t1.name, t2.salary FROM
employee AS t1, info AS t2
->
where
t1.name = t2.name;
->
WHERE
t1.name = t2.name;
@end example
@end example
@item
@item
...
@@ -33397,9 +33397,9 @@ If there is no matching record for the right table in the @code{ON} or
...
@@ -33397,9 +33397,9 @@ If there is no matching record for the right table in the @code{ON} or
records in a table that have no counterpart in another table:
records in a table that have no counterpart in another table:
@example
@example
mysql>
select table1.* from
table1
mysql>
SELECT table1.* FROM
table1
-> LEFT JOIN table2 ON table1.id=table2.id
-> LEFT JOIN table2 ON table1.id=table2.id
->
where table2.id is
NULL;
->
WHERE table2.id IS
NULL;
@end example
@end example
This example finds all rows in @code{table1} with an @code{id} value that is
This example finds all rows in @code{table1} with an @code{id} value that is
...
@@ -34293,7 +34293,7 @@ The @code{IGNORE number LINES} option can be used to ignore a header of
...
@@ -34293,7 +34293,7 @@ The @code{IGNORE number LINES} option can be used to ignore a header of
column names at the start of the file:
column names at the start of the file:
@example
@example
mysql> LOAD DATA INFILE "/tmp/file_name"
into table
test IGNORE 1 LINES;
mysql> LOAD DATA INFILE "/tmp/file_name"
INTO TABLE
test IGNORE 1 LINES;
@end example
@end example
When you use @code{SELECT ... INTO OUTFILE} in tandem with @code{LOAD
When you use @code{SELECT ... INTO OUTFILE} in tandem with @code{LOAD
...
@@ -35089,9 +35089,9 @@ MySQL will create new fields for all elements in the
...
@@ -35089,9 +35089,9 @@ MySQL will create new fields for all elements in the
@code{SELECT}. For example:
@code{SELECT}. For example:
@example
@example
mysql> CREATE TABLE test (a
int not null auto_increment
,
mysql> CREATE TABLE test (a
INT NOT NULL AUTO_INCREMENT
,
->
primary key (a), key
(b))
->
PRIMARY KEY (a), KEY
(b))
-> TYPE=MyISAM SELECT b,c
from
test2;
-> TYPE=MyISAM SELECT b,c
FROM
test2;
@end example
@end example
This will create a @code{MyISAM} table with three columns, a, b, and c.
This will create a @code{MyISAM} table with three columns, a, b, and c.
...
@@ -35100,18 +35100,18 @@ the right side of the table, not overlapped onto it. Take the following
...
@@ -35100,18 +35100,18 @@ the right side of the table, not overlapped onto it. Take the following
example:
example:
@example
@example
mysql>
select * from
foo;
mysql>
SELECT * FROM
foo;
+---+
+---+
| n |
| n |
+---+
+---+
| 1 |
| 1 |
+---+
+---+
mysql>
create table bar (m int) select n from
foo;
mysql>
CREATE TABLE bar (m INT) SELECT n FROM
foo;
Query OK, 1 row affected (0.02 sec)
Query OK, 1 row affected (0.02 sec)
Records: 1 Duplicates: 0 Warnings: 0
Records: 1 Duplicates: 0 Warnings: 0
mysql>
select * from
bar;
mysql>
SELECT * FROM
bar;
+------+---+
+------+---+
| m | n |
| m | n |
+------+---+
+------+---+
...
@@ -35129,7 +35129,7 @@ possible. If you want to have indexes in the created table, you should
...
@@ -35129,7 +35129,7 @@ possible. If you want to have indexes in the created table, you should
specify these before the @code{SELECT} statement:
specify these before the @code{SELECT} statement:
@example
@example
mysql>
create table bar (unique (n)) select n from
foo;
mysql>
CREATE TABLE bar (UNIQUE (n)) SELECT n FROM
foo;
@end example
@end example
If any errors occur while copying the data to the table, it will
If any errors occur while copying the data to the table, it will
...
@@ -35915,9 +35915,9 @@ example shown below requires @code{LOCK TABLES} in order to execute safely:
...
@@ -35915,9 +35915,9 @@ example shown below requires @code{LOCK TABLES} in order to execute safely:
@example
@example
mysql> LOCK TABLES trans READ, customer WRITE;
mysql> LOCK TABLES trans READ, customer WRITE;
mysql>
select sum(value) from trans where customer_id=
some_id;
mysql>
SELECT SUM(value) FROM trans WHERE customer_id=
some_id;
mysql>
update customer set
total_value=sum_from_previous_statement
mysql>
UPDATE customer SET
total_value=sum_from_previous_statement
->
where
customer_id=some_id;
->
WHERE
customer_id=some_id;
mysql> UNLOCK TABLES;
mysql> UNLOCK TABLES;
@end example
@end example
...
@@ -37233,6 +37233,7 @@ INSERT INTO t2 (message) VALUES ("Testing"),("table"),("t2");
...
@@ -37233,6 +37233,7 @@ INSERT INTO t2 (message) VALUES ("Testing"),("table"),("t2");
CREATE TABLE total (a INT NOT NULL, message CHAR(20), KEY(a))
CREATE TABLE total (a INT NOT NULL, message CHAR(20), KEY(a))
TYPE=MERGE UNION=(t1,t2) INSERT_METHOD=LAST;
TYPE=MERGE UNION=(t1,t2) INSERT_METHOD=LAST;
@end example
@end example
@c CAPPING DONE TO HERE
Note that we didn't create a @code{UNIQUE} or @code{PRIMARY KEY} in the
Note that we didn't create a @code{UNIQUE} or @code{PRIMARY KEY} in the
@code{total} table as the key isn't going to be unique in the @code{total}
@code{total} table as the key isn't going to be unique in the @code{total}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment