html { font-family: sans-serif }
body { margin: 0 }
article,aside,details,figcaption,figure,footer,header,hgroup,main,nav,section,summary { display: block }
audio,canvas,progress,video { display: inline-block; vertical-align: baseline }
audio:not([controls]) { display: none; height: 0 }
[hidden],template { display: none }
a { background: transparent }
a:active,a:hover { outline: 0 }
abbr[title] { border-bottom: 1px dotted }
b,strong { font-weight: bold }
dfn { font-style: italic }
h1 { font-size: 2em; margin: 0.67em 0 }
mark { background: #ff0; color: #000 }
small { font-size: 80% }
sub,sup { font-size: 75%; line-height: 0; position: relative; vertical-align: baseline }
sup { top: -0.5em }
sub { bottom: -0.25em }
img { border: 0 }
svg:not(:root) { overflow: hidden }
figure { margin: 1em 40px }
hr { height: 0 }
pre { overflow: auto }
code,kbd,pre,samp { font-family: monospace, monospace; font-size: 1em }
button,input,optgroup,select,textarea { color: inherit; font: inherit; margin: 0 }
button { overflow: visible }
button,select { text-transform: none }
button,html input[type="button"],input[type="reset"],input[type="submit"] { cursor: pointer }
button[disabled],html input[disabled] { cursor: default }
button::-moz-focus-inner,
input::-moz-focus-inner { border: 0; padding: 0 }
input { line-height: normal }
input[type="checkbox"],input[type="radio"] { padding: 0 }
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { height: auto }
input[type="search"] { }
input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-decoration { }
fieldset { border: 1px solid #c0c0c0; margin: 0 2px; padding: 0.35em 0.625em 0.75em }
legend { border: 0; padding: 0 }
textarea { overflow: auto }
optgroup { font-weight: bold }
table { border-collapse: collapse; border-spacing: 0 }
td,th { padding: 0 }
* { }
*::before,*::after { }
html { font-size: 62.5% }
body { font-family: "Helvetica Neue", Helvetica, Arial, "Microsoft Yahei", sans-serif; font-size: 14px; line-height: 1.42857143; color: #333333 }
input,button,select,textarea { font-family: inherit; font-size: inherit; line-height: inherit }
a { color: #428bca; text-decoration: none }
a:hover,a:focus { color: #2a6496; text-decoration: underline }
a:focus { outline: 5px auto -webkit-focus-ring-color }
figure { margin: 0 }
img { vertical-align: middle }
.hljs { display: block; padding: 0.5em; color: #333; background: #f8f8f8 }
.hljs-comment,.hljs-template_comment,.diff .hljs-header,.hljs-javadoc { color: #998; font-style: italic }
.hljs-keyword,.css .rule .hljs-keyword,.hljs-winutils,.javascript .hljs-title,.nginx .hljs-title,.hljs-subst,.hljs-request,.hljs-status { color: #333; font-weight: bold }
.hljs-number,.hljs-hexcolor,.ruby .hljs-constant { color: #099 }
.hljs-string,.hljs-tag .hljs-value,.hljs-phpdoc,.tex .hljs-formula { color: #d14 }
.hljs-title,.hljs-id,.coffeescript .hljs-params,.scss .hljs-preprocessor { color: #900; font-weight: bold }
.javascript .hljs-title,.lisp .hljs-title,.clojure .hljs-title,.hljs-subst { font-weight: normal }
.hljs-class .hljs-title,.haskell .hljs-type,.vhdl .hljs-literal,.tex .hljs-command { color: #458; font-weight: bold }
.hljs-tag,.hljs-tag .hljs-title,.hljs-rules .hljs-property,.django .hljs-tag .hljs-keyword { color: #000080; font-weight: normal }
.hljs-attribute,.hljs-variable,.lisp .hljs-body { color: #008080 }
.hljs-regexp { color: #009926 }
.hljs-symbol,.ruby .hljs-symbol .hljs-string,.lisp .hljs-keyword,.tex .hljs-special,.hljs-prompt { color: #990073 }
.hljs-built_in,.lisp .hljs-title,.clojure .hljs-built_in { color: #0086b3 }
.hljs-preprocessor,.hljs-pragma,.hljs-pi,.hljs-doctype,.hljs-shebang,.hljs-cdata { color: #999; font-weight: bold }
.hljs-deletion { background: #fdd }
.hljs-addition { background: #dfd }
.diff .hljs-change { background: #0086b3 }
.hljs-chunk { color: #aaa }
#container { padding: 15px }
pre { border: 1px solid #ccc; display: block; background-color: #f8f8f8 }
pre code { white-space: pre-wrap }
.hljs,code { font-family: Monaco, Menlo, Consolas, "Courier New", monospace }
:not(pre)>code { padding: 2px 4px; font-size: 90%; color: #c7254e; background-color: #f9f2f4; white-space: nowrap }
本文为mariadb官方手册:DATABASE的译文。
原文:https://mariadb.com/kb/en/library/database/
我提交到MariaDB官方手册的译文:https://mariadb.com/kb/zh-cn/database/
语法
DATABASE()
描述
以utf8 character set 格式的字符串返回默认(当前)的数据库名称。如果没有默认的数据库,则DATABASE()将返回NULL。在存储过程中,默认数据库是过程所关联的数据库,它可以和调用过程的上下文的默认数据库不同。
SCHEMA() 是 DATABASE()的同义词。
可以使用USE语句指定默认的数据库。另一种设置默认数据库的方式是在mysql命令行客户端启动时指定数据库的名称。
示例
MariaDB [(none)]> SELECT DATABASE();
+------------+
| DATABASE() |
+------------+
| NULL |
+------------+
MariaDB [(none)]> USE test
Database changed
MariaDB [test]> SELECT DATABASE();
+------------+
| DATABASE() |
+------------+
| test |
+------------+