Skip to content
Closed
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 75 additions & 1 deletion docs/sql-ref-syntax-aux-describe-database.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,79 @@ license: |
See the License for the specific language governing permissions and
limitations under the License.
---
### Description
`DESCRIBE DATABASE` statement returns the metadata of an existing database. The metadata information includes database
name, database comment, and database location on the filesystem. If the optional `EXTENDED` option is specified, it
returns the basic metadata information along with the database properties. The `DATABASE` and `SCHEMA` are
interchangeable.

**This page is under construction**
### Syntax
{% highlight sql %}
{DESC | DESCRIBE} DATABASE [EXTENDED] db_name
{% endhighlight %}

### Parameters
<dl>
<dt><code><em>db_name</em></code></dt>
<dd>
Specifies a name of an existing database or an existing schema in the syetem. If the name does not exist, an
exception is thrown. The name is case insensitive, it is stored as low case in SPARK<br><br>
</dd>
</dl>

### Example
{% highlight sql %}
-- Create employees DATABASE
CREATE DATABASE EMPLOYEES COMMENT 'For software companies';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kevinyu98 lets use lowercase for EMPLOYEES to match other PRS..

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


-- Describe employees DATABASE.
-- Returns Database Name, Description and Root location of the filesystem for the employees DATABASE

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kevinyu98 Can we please put DATABASE in another line with a comment marker. ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

DESCRIBE DATABASE Employees;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kevinyu98 ditto.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed

+-------------------------+-----------------------------+

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kevinyu98 Can we keep the results 2 spaces to the right to match other PRs.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed

|database_description_item|database_description_value |
+-------------------------+-----------------------------+
|Database Name |employees |
|Description |For software companies |
|Location |file:/Users/Temp/employees.db|
+-------------------------+-----------------------------+
{% endhighlight %}

{% highlight sql %}
-- Create employees DATABASE
CREATE DATABASE EMPLOYEES COMMENT 'For software companies';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kevinyu98 lowercase employees.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok


-- Alter employees database to set DBPROPERTIES
ALTER DATABASE EMPLOYEES SET DBPROPERTIES ('Create-by' = 'Kevin', 'Create-date' = '09/01/2019');

-- Describe employees DATABASE with EXTENDED option to the database properties

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kevinyu98 "to return additional database properties"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

DESCRIBE DATABASE EXTENDED employees;
+-------------------------+---------------------------------------------+
|database_description_item|database_description_value |
+-------------------------+---------------------------------------------+
|Database Name |employees |
|Description |For software companies |
|Location |file:/Users/Temp/employees.db |
|Properties |((Create-by,kevin), (Create-date,09/01/2019))|
+-------------------------+---------------------------------------------+
{% endhighlight %}

{% highlight sql %}
-- Create deployment SCHEMA
CREATE SCHEMA DEPLOYMENT comment 'Deployment environment';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kevinyu98 lowercase ..

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok


-- Describe deployment, the DATABASE and SCHEMA are interchangeable, their meaning are the same.
DESC DATABASE DEPLOYMENT;
+-------------------------+------------------------------+
|database_description_item|database_description_value |
+-------------------------+------------------------------+
|Database Name |deployment |
|Description |Deployment environment |
|Location |file:/Users/Temp/deployment.db|
+-------------------------+------------------------------+
{% endhighlight %}

### Related Statements
- [DESCRIBE FUNCTION](sql-ref-syntax-aux-describe-function.html)
- [DESCRIBE TABLE](sql-ref-syntax-aux-describe-table.html)
- [DESCRIBE QUERY](sql-ref-syntax-aux-describe-query.html)