User Management

List of Contents

This chapter explains how to create and drop a new user account.

CREATE USER

Syntax:

CREATE USER user_name IDENTIFIED BY password;

Example:

CREATE USER mach IDENTIFIED BY machbase;

DROP USER

This statement deletes a user. However, a SYS user cannot be deleted. When trying to delete the user that already has a table, an error occurs.

Syntax:

DROP USER user_name;

Example:

DROP USER mach;

Change User Password

This statement below enables a user to change the password.

Syntax:

ALTER USER user_name IDENTIFIED BY password;

Example:

ALTER USER mach IDENTIFIED BY manager;

User Reconnection

A user is able to reconnect via the statement below without disconnecting the application.

Syntax:

CONNECT user_name/password;

Example:

# Connect SYS: connect with the SYS account.

Mach> CREATE USER demo IDENTIFIED BY demo;
Created successfully.

Mach> DROP USER demo;
Dropped successfully.

Mach> CREATE USER demo1 IDENTIFIED BY password1;
Created successfully.

Mach> CREATE USER demo2 IDENTIFIED BY password2;
Created successfully.

Mach> ALTER USER demo2 IDENTIFIED BY newpassword2;
Altered successfully.

Mach> DROP USER sys;
[ERR-02083 : You cannot drop yourself(SYS).]

Mach>CONNECT demo1/password1;
Connected successfully.

Mach>ALTER USER demo2 IDENTIFIED BY demo22;
[ERR-02085 : The user(DEMO2) does not have alter privileges.]

Mach>ALTER USER demo1 IDENTIFIED BY newpassword1;
Altered successfully.

Mach>CONNECT demo2/newpassword2;
Connected successfully.

Mach>CONNECT demo1/demo11234;
[ERR-02081 : Invalid username/password.]

Mach>CONNECT demo1/newpassword1;
Connected successfully.

Mach>CREATE TABLE demo1_table (id INTEGER);
Connected successfully.

Mach>CREATE INDEX demo_idx ON demo1_table(id);
Connected successfully.

Mach>INSERT INTO demo1_table VALUES(1);
1 row(s) inserted.

Mach>INSERT INTO demo1_table VALUES(2);
1 row(s) inserted.

# Connect SYS again
Mach>CONNECT sys/manager;
Connected successfully.

Mach>DROP USER demo1;
[ERR-02084 : User drop error. The user tables still exist. Drop those tables first.]

Mach>CONNECT DEMO1/newpassword1;
Connected successfully.

Mach>DROP TABLE demo1_table;
Dropped successfully.

Mach>CONNECT sys/manager;
Connected successfully.

Mach>DROP USER demo1;
Dropped successfully.

results matching ""

    No results matching ""