English 中文(简体)
Apache Tajo - Database Creation
  • 时间:2024-12-22

Apache Tajo - Database Creation


Previous Page Next Page  

This section explains the Tajo DDL commands. Tajo has a built-in database named default.

Create Database Statement

Create Database is a statement used to create a database in Tajo. The syntax for this statement is as follows −

CREATE DATABASE [IF NOT EXISTS] <database_name> 

Query

default> default> create database if not exists test; 

Result

The above query will generate the following result.

OK

Database is the namespace in Tajo. A database can contain multiple tables with a unique name.

Show Current Database

To check the current database name, issue the following command −

Query

default> c 

Result

The above query will generate the following result.

You are now connected to database "default" as user “user1". 
default>  

Connect to Database

As of now, you have created a database named “test”. The following syntax is used to connect the “test” database.

c <database name> 

Query

default> c test 

Result

The above query will generate the following result.

You are now connected to database "test" as user “user1”. 
test>

You can now see the prompt changes from default database to test database.

Drop Database

To drop a database, use the following syntax −

DROP DATABASE <database-name> 

Query

test> c default 
You are now connected to database "default" as user “user1". 
default> drop database test; 

Result

The above query will generate the following result.

OK 
Advertisements