---
title: "USE"
url: "https://docs.yugabyte.com/stable/api/ycql/ddl_use/"
---

# USE

Use the USE statement to specify a default keyspace for the current client session.

## Synopsis

Use the `USE` statement to specify a default keyspace for the current client session. When a database object (such as [table](/stable/api/ycql/ddl_create_table "table") or [type](/stable/api/ycql/ddl_create_type "type")) name does not identify a keyspace, this default keyspace is used.

## Syntax

### Diagram

USE[keyspace\_name](/stable/api/ycql/grammar_diagrams#keyspace-name)

### Grammar

```ebnf
use_keyspace ::= USE keyspace_name;
```

Where

- `keyspace_name` must be an identifier that cannot be any reserved keyword and cannot contains whitespaces, or it has to be double-quoted.

## Semantics

- If the specified keyspace does not exist, an error is raised.
- Any unqualified table or type name will use the current default keyspace (or raise an error if no keyspace is set).

## Examples

### Create and use keyspaces

```sql
ycqlsh> CREATE KEYSPACE example;
```

```sql
ycqlsh> CREATE KEYSPACE other_keyspace;
```

```sql
ycqlsh> USE example;
```

### Create a table in the current keyspace

```sql
ycqlsh:example> CREATE TABLE test(id INT PRIMARY KEY);
ycqlsh:example> INSERT INTO test(id) VALUES (1);
ycqlsh:example> SELECT * FROM test;
```

```output
 id
----
  1
```

### Create a table in another keyspace

```sql
ycqlsh:example> CREATE TABLE other_keyspace.test(id INT PRIMARY KEY);
ycqlsh:example> INSERT INTO other_keyspace.test(id) VALUES (2);
ycqlsh:example> SELECT * FROM other_keyspace.test;
```

```output
 id
----
  2
```

## See also

- [ALTER KEYSPACE](/stable/api/ycql/ddl_alter_keyspace "ALTER KEYSPACE")
- [CREATE KEYSPACE](/stable/api/ycql/ddl_create_keyspace "CREATE KEYSPACE")
- [DROP KEYSPACE](/stable/api/ycql/ddl_drop_keyspace "DROP KEYSPACE")
