SurrealDB Docs Logo

Enter a search query

INFO statement

The INFO command outputs information about the setup of the SurrealDB system. There are a number of different INFO commands for retrieving the configuration at the different levels of the database.

SurrealQL Syntax
INFO FOR [ ROOT | NS | NAMESPACE | DB | DATABASE | TABLE @table | USER @user [ON @level] | INDEX @index ON @level ];

The information returned from an INFO command is an object containing items that almost always correspond to a matching DEFINE statement. For example, the INFO FOR NS command returns the information on the access methods, databases and users of a namespace, which are defined with DEFINE ACCESS, DEFINE DATABASE and DEFINE USER statements.

Example usage

There are a number of different INFO commands for retrieving the configuration at the different levels of the database.

System information

Root information

The top-level ROOT command returns information regarding the users and namespaces which exists within the SurrealDB system.

Note

You must be authenticated as a top-level root user to execute this command.

Examples

INFO FOR ROOT;
Sample output
{ "namespaces": { "ns": "DEFINE NAMESPACE ns" }, "users": { "example": "DEFINE USER example ON ROOT PASSHASH '$argon2id$v=19$m=19456,t=2,p=1$S8ggGUFSZY9B6+ZUJADNAw$jcFYLOrx1tq+/YlVk63QNZcP+VbsGD8lpFPvM59aZF4' ROLES OWNER" } }

Namespace information

The NS or NAMESPACE command returns information regarding the users, databases and access methods under the namespace in use.

Note

You must be authenticated as a top-level root user, or a namespace user to execute this command.

Note

You must have a NAMESPACE selected before running this command.

Examples

INFO FOR NS;
Sample output
{ "accesses": {}, "databases": { "db": "DEFINE DATABASE db" }, "users": { "ns_user": "DEFINE USER ns_user ON NAMESPACE PASSHASH '$argon2id$v=19$m=19456,t=2,p=1$da30XYKIjHauYbW6CyqgXQ$4rnHoGa3itfY6LarGE/KwoZE+N+AXrydklDXUFUZXGQ' ROLES OWNER" } }

Database information

The DB or DATABASE command returns information regarding the users, tables, params, models, functions, analyzers and access methods under the database in use.

Note

You must be authenticated as a top-level root user, a namespace user, or a database user to execute this command.

Note

You must have a NAMESPACE and a DATABASE selected before running this command.

Examples

INFO FOR DB;
Sample output
{ "accesses": {}, "analyzers": {}, "functions": {}, "models": {}, "params": {}, "tables": { "person": "DEFINE TABLE person TYPE ANY SCHEMALESS PERMISSIONS NONE" }, "users": { "db_user": "DEFINE USER db_user ON DATABASE PASSHASH '$argon2id$v=19$m=19456,t=2,p=1$FhgETjyVbEZmcLiCHf5fCA$zXOb8b0lIzIRrtaLPpWXHlWylC4VFBsfr4SWPF3WBKE' ROLES OWNER" } }

“accesses”: ,

Table information

The TABLE command returns information regarding the events, fields, tables, and live statement configurations on a specific table.

Note

You must be authenticated as a top-level root user, a namespace user, or a database user to execute this command.

Note

You must have a NAMESPACE and a DATABASE selected before running this command.

Examples

INFO FOR TABLE user;
Sample output
{ "events": {}, "fields": { "name": "DEFINE FIELD name ON user TYPE string PERMISSIONS FULL" }, "indexes": {}, "lives": {}, "tables": {} }

User information

The USER command returns information for a user defined on either the root, namespace, or database level.

Note

You must be authenticated as a user equal to or greater than the level of the user you are attempting to obtain information for to execute this command.

Examples

INFO FOR USER root ON ROOT; INFO FOR USER ns_user ON NAMESPACE; INFO FOR USER db_user ON DATABASE;

If a level after ON is not specified, the INFO command will default to the database level. Thus, the following two commands are equivalent.

INFO FOR USER db_user ON DATABASE;
INFO FOR USER db_user;
Sample output
"DEFINE USER db_user ON DATABASE PASSHASH '$argon2id$v=19$m=19456,t=2,p=1$LvgY4ZdWBt5YR+TXd6SNJg$INeqLI5l9vhDtkDGOR2otZMsJHQcT60HtBGgT6F5I9s' ROLES OWNER"

Index information

INFO FOR INDEX returns the status for an index: started, initial indexing, update indexing, built, or error.

This command only applies when the CONCURRENTLY clause is used in a DEFINE INDEX command. Without this clause, the following statement will not be executed until the index is fully created, or fails. In this case, the INFO FOR INDEX statement will return an empty object: {}.

CREATE |user:50000| SET name = id.id() RETURN NONE; DEFINE INDEX unique_name ON TABLE user FIELDS name UNIQUE; INFO FOR INDEX unique_name ON TABLE user;

However, when the CONCURRENTLY clause is used, the index will build in the background while other statements are permitted to run. In this case, the INFO FOR INDEX statement will provide the current status on the index. The following code sample shows such an example in which an index is defined on a large number of records. A SLEEP statement is run in between each INFO FOR INDEX command to show the progress after each 50 millisecond interval.

CREATE |user:50000| SET name = id.id() RETURN NONE; DEFINE INDEX unique_name ON TABLE user FIELDS name UNIQUE CONCURRENTLY; INFO FOR INDEX unique_name ON TABLE user; SLEEP 50ms; INFO FOR INDEX unique_name ON TABLE user; SLEEP 50ms; INFO FOR INDEX unique_name ON TABLE user; SLEEP 50ms; INFO FOR INDEX unique_name ON TABLE user;
Possible output
-------- Query 1 -------- { building: { count: 0, status: 'initial' } } -------- Query 2 -------- { building: { count: 17250, status: 'initial' } } -------- Query 3 -------- { building: { count: 33542, status: 'initial' } } -------- Query 4 -------- { building: { status: 'built' } }

The STRUCTURE clause

Note

This clause was originally created for internal use and is subject to change without notice.

Adding the STRUCTURE clause changes the structure of the statement from an object that contains objects into an object with fields that each contain an array and often extra info.

DEFINE TABLE user SCHEMAFULL; DEFINE FIELD name ON user TYPE STRING; INFO FOR TABLE user; INFO FOR TABLE user STRUCTURE;
Output
-------- Query -------- { events: {}, fields: { name: 'DEFINE FIELD name ON user TYPE string PERMISSIONS FULL' }, indexes: {}, lives: {}, tables: {} } -------- Query -------- { events: [], fields: [ { flex: false, kind: 'string', name: 'name', permissions: { create: true, delete: true, select: true, update: true }, readonly: false, what: 'user' } ], indexes: [], lives: [], tables: [] }
© SurrealDB GitHub Discord Community Cloud Features Releases Install