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
58ba644a
Commit
58ba644a
authored
Jul 05, 2001
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added new examples to the manual.
Docs/manual.texi: Added new example Updated 4.0 changelog
parent
55ffd19f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
90 additions
and
17 deletions
+90
-17
Docs/manual.texi
Docs/manual.texi
+90
-17
No files found.
Docs/manual.texi
View file @
58ba644a
...
...
@@ -632,6 +632,7 @@ Examples of Common Queries
* example-user-variables:: Using user variables
* example-Foreign keys:: Using foreign keys
* Searching on two keys::
* Calculating days::
Queries from Twin Project
...
...
@@ -16536,6 +16537,7 @@ mysql> select 2 > 2;
-> 0
@end example
@cindex @code{NULL}, testing for null
@findex <=> (Equal to)
@item <=>
Null safe equal:
...
...
@@ -16544,6 +16546,7 @@ mysql> select 1 <=> 1, NULL <=> NULL, 1 <=> NULL;
-> 1 1 0
@end example
@cindex @code{NULL}, testing for null
@findex IS NULL
@findex IS NOT NULL
@item IS NULL
...
...
@@ -16628,6 +16631,7 @@ mysql> select ISNULL(1/0);
Note that a comparison of @code{NULL} values using @code{=} will always be
false!
@cindex @code{NULL}, testing for null
@findex COALESCE()
@item COALESCE(list)
Returns first non-@code{NULL} element in list:
...
...
@@ -16845,6 +16849,7 @@ make string comparison even more flexible.
@subsection Control Flow Functions
@table @code
@cindex @code{NULL}, testing for null
@findex IFNULL()
@item IFNULL(expr1,expr2)
If @code{expr1} is not @code{NULL}, @code{IFNULL()} returns @code{expr1},
...
...
@@ -17121,10 +17126,13 @@ mysql> select SQRT(20);
@findex PI()
@item PI()
Returns the value of PI:
Returns the value of PI. The default shown number of decimals is 5, but
@strong{MySQL} internally uses the full double precession for PI.
@example
mysql> select PI();
-> 3.141593
mysql> SELECT PI()+0.000000000000000000;
-> 3.141592653589793116
@end example
@findex COS()
...
...
@@ -19253,7 +19261,7 @@ The options work for all table types, if not otherwise indicated:
@item @code{PACK_KEYS} @tab Set this to 1 if you want to have a smaller index. This usually makes updates slower and reads faster (MyISAM, ISAM).
@item @code{PASSWORD} @tab Encrypt the @code{.frm} file with a password. This option doesn't do anything in the standard @strong{MySQL} version.
@item @code{DELAY_KEY_WRITE} @tab Set this to 1 if want to delay key table updates until the table is closed (MyISAM).
@item @code{ROW_FORMAT} @tab Defines how the rows should be stored
(for the future)
.
@item @code{ROW_FORMAT} @tab Defines how the rows should be stored
. Currently you can only use the DYNAMIC and STATIC options for MyISAM tables
.
@end multitable
When you use a @code{MyISAM} table, @strong{MySQL} uses the product of
...
...
@@ -19444,9 +19452,8 @@ normally do @code{ALTER TABLE} that often this isn't that high on our TODO.
@itemize @bullet
@item
To use @code{ALTER TABLE}, you need @strong{select}, @strong{insert},
@strong{delete}, @strong{update}, @strong{create}, and @strong{drop}
privileges on the table.
To use @code{ALTER TABLE}, you need @strong{ALTER}, @strong{INSERT},
and @strong{CREATE} privileges on the table.
@item
@code{IGNORE} is a @strong{MySQL} extension to ANSI SQL92.
...
...
@@ -19536,7 +19543,7 @@ assigns a default value, as described in
@findex DROP INDEX
@item
@code{DROP INDEX} removes an index. This is a @strong{MySQL} extension to
ANSI SQL92.
ANSI SQL92.
@xref{DROP INDEX}.
@item
If columns are dropped from a table, the columns are also removed from any
...
...
@@ -22228,8 +22235,8 @@ tables to use the slower key cache method to create the index.
@strong{NOTE} that this parameter is given in megabytes!
@item @code{myisam_max_sort_file_size}
The maximum size of the temporary file @strong{MySQL} is allowed to
creat
e
to
while recreating the index (during @code{REPAIR}, @code{ALTER TABLE}
The maximum size of the temporary file @strong{MySQL} is allowed to
us
e
while recreating the index (during @code{REPAIR}, @code{ALTER TABLE}
or @code{LOAD DATA INFILE}. If the file size would be bigger than this,
the index will be created through the key cache (which is slower).
@strong{NOTE} that this parameter is given in megabytes!
...
...
@@ -22544,8 +22551,23 @@ combination after it has found the first matching row.
@item Not exists
@strong{MySQL} was able to do a @code{LEFT JOIN} optimization on the
query and will not examine more rows in this table for a row combination
after it finds one row that matches the @code{LEFT JOIN} criteria.
query and will not examine more rows in this table for the previous row
combination after it finds one row that matches the @code{LEFT JOIN} criteria.
Here is an example for this:
@example
SELECT * FROM t1 LEFT JOIN t2 ON t1.id=t2.id WHERE t2.id IS NULL;
@end example
Assume that @code{t2.id} is defined with @code{NOT NULL}. In this case
@strong{MySQL} will scan @code{t1} and look up the rows in @code{t2}
through @code{t1.id}. If @strong{MySQL} finds a matching row in
@code{t2}, it knows that @code{t2.id} can never be @code{NULL}, and will
not scan through the rest of the rows in @code{t2} that has the same
@code{id}. In other words, for each row in @code{t1}, @strong{MySQL}
only needs to do a single lookup in @code{t2}, independent of how many
matching rows there are in @code{t2}.
@item @code{range checked for each record (index map: #)}
@strong{MySQL} didn't find a real good index to use. It will, instead, for
...
...
@@ -22802,6 +22824,9 @@ the @code{FROM} clause.
@{DESCRIBE | DESC@} tbl_name @{col_name | wild@}
@end example
@code{DESCRIBE} is a shortcut for @code{SHOW COLUMNS FROM}.
@xref{SHOW DATABASE INFO}.
@code{DESCRIBE} provides information about a table's columns. @code{col_name}
may be a column name or a string containing the SQL @samp{%} and @samp{_}
wild-card characters.
...
...
@@ -22893,6 +22918,18 @@ are locked by the current thread are automatically unlocked when the
thread issues another @code{LOCK TABLES}, or when the connection to the
server is closed.
The main reasons to use @code{LOCK TABLES} are:
@itemize @bullet
@item
Emulate transactions with not transaction safe tables.
@item
To get more speed with @code{MyISAM} tables when inserting/updating data
over many statements. The main reason this gives more speed is that
@strong{MySQL} will not flush the key cache for the locked tables until
@code{UNLOCK TABLES} is called.
@end itemize
If a thread obtains a @code{READ} lock on a table, that thread (and all other
threads) can only read from the table. If a thread obtains a @code{WRITE}
lock on a table, then only the thread holding the lock can @code{READ} from
...
...
@@ -24417,7 +24454,7 @@ mysql> ALTER TABLE tbl_name TYPE = MYISAM;
@end example
@cindex tables, @code{HEAP}
@node HEAP,
B
DB, ISAM, Table types
@node HEAP,
Inno
DB, ISAM, Table types
@section HEAP Tables
@code{HEAP} tables use a hashed index and are stored in memory. This
...
...
@@ -24494,7 +24531,7 @@ SUM_OVER_ALL_KEYS(max_length_of_key + sizeof(char*) * 2)
@code{sizeof(char*)} is 4 on 32-bit machines and 8 on 64-bit machines.
@node InnoDB,
, GEMINI
, Table types
@node InnoDB,
BDB, HEAP
, Table types
@section InnoDB Tables
@menu
...
...
@@ -25795,7 +25832,7 @@ Finland
@cindex tables, @code{BDB}
@cindex tables, @code{Berkeley DB}
@node BDB, GEMINI,
HEAP
, Table types
@node BDB, GEMINI,
InnoDB
, Table types
@section BDB or Berkeley_DB Tables
@menu
...
...
@@ -26081,7 +26118,7 @@ not trivial).
@end itemize
@cindex GEMINI tables
@node GEMINI,
InnoDB
, BDB, Table types
@node GEMINI,
, BDB, Table types
@section GEMINI Tables
@cindex GEMINI tables, overview
...
...
@@ -28698,6 +28735,7 @@ mysql> SELECT * FROM shop;
* example-user-variables:: Using user variables
* example-Foreign keys:: Using foreign keys
* Searching on two keys::
* Calculating days::
@end menu
@node example-Maximum-column, example-Maximum-row, Examples, Examples
...
...
@@ -28954,7 +28992,7 @@ SELECT s.* FROM persons p, shirts s
@findex UNION
@cindex searching, two keys
@cindex keys, searching on two
@node Searching on two keys,
, example-Foreign keys, Examples
@node Searching on two keys,
Calculating days
, example-Foreign keys, Examples
@subsection Searching on Two Keys
@strong{MySQL} doesn't yet optimize when you search on two different
...
...
@@ -28986,6 +29024,35 @@ DROP TABLE tmp;
The above way to solve this query is in effect an @code{UNION} of two queries.
@cindex bit_functions, example
@findex BIT_OR
@findex BIT_COUNT
@findex <<
@node Calculating days, , Searching on two keys, Examples
@subsection Calculating visits per day
The following shows an idea of how you can use the bit group functions
to calculate the number of days per month a user has visited a web page.
@example
CREATE TABLE t1 (year YEAR(4), month INT(2) UNSIGNED ZEROFILL, day INT(2) UNSIGNED ZEROFILL);
INSERT INTO t1 VALUES(2000,1,1),(2000,1,20),(2000,1,30),(2000,2,2),(2000,2,23),(2000,2,23);
SELECT year,month,BIT_COUNT(BIT_OR(1<<day)) AS days FROM t1 GROUP BY year,month;
Which returns:
+------+-------+------+
| year | month | days |
+------+-------+------+
| 2000 | 01 | 3 |
| 2000 | 02 | 2 |
+------+-------+------+
@end example
The above calculates how many different days was used for a given
year/month combination, with automatic removal of duplicate entries.
@cindex modes, batch
@cindex batch mode
@cindex running, batch mode
...
...
@@ -39155,7 +39222,7 @@ directory and delete all files that have names starting with @code{A-} or
If something goes wrong with the renaming operation, @strong{MySQL} tries to
undo the changes. If something goes seriously wrong (this shouldn't happen,
of course), @strong{MySQL} may leave the old table as @file{B-xxx}, but a
simple rename should get your data back.
simple rename
on the system level
should get your data back.
@cindex reordering, columns
@cindex columns, changing
...
...
@@ -46344,6 +46411,12 @@ Our TODO section contains what we plan to have in 4.0. @xref{TODO MySQL 4.0}.
@itemize @bullet
@item
Don't anymore support the client protocol prior to 3.21.
@item
Don't include the old C API functions @code{mysql_drop_db},
@code{mysql_create_db} and @code{mysql_connect}, if not compiled with
@code{USE_OLD_FUNCTIONS}.
@item
Renamed @code{safe_mysqld} to @code{mysqld_safe}.
@item
Allow one to use @code{IN} instead of @code{FROM} in @code{SHOW} commands.
...
...
@@ -51804,7 +51877,7 @@ The @code{mysqld} will support all standard @strong{MySQL} features and
one can use it in a threaded client to run different queries in each
thread.
@item
Replication should work with @code{RAND()}.
Replication should work with @code{RAND()}
and user variables @code{@@var}
.
@item
Online backup with very low performance penalty. The online backup will
make it easy to add a new replication slave without taking down the
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