SQL Schemas
A SQL schema is a namespace in the Redpanda SQL database. A schema groups objects so that their names do not collide. Use schemas to organize views and to control which users can create views.
|
On this page, schema means a SQL namespace in the PostgreSQL sense. It is not the same as a topic’s serialization schema (Protobuf, Avro, or JSON) registered in Schema Registry. It is also not an Iceberg namespace, such as the namespace of a table in an Iceberg catalog. |
What a schema holds
Each schema can hold:
-
Catalog connections, such as
default_redpanda_cataloganddefault_iceberg_catalog. -
SQL storage definitions that you create with
CREATE STORAGE. -
Views that you create with
CREATE VIEW.
Tables are not in a schema. A table belongs to a catalog. You name a table through its catalog, such as default_redpanda_catalog=>orders. To map a topic to a table, see CREATE TABLE. For where tables and views are stored, see Where tables and views live.
Built-in schemas
Redpanda SQL provides these built-in schemas:
-
public: The default schema. Objects that you create without naming a schema go here, unless you change the search path. It holds the default catalog connections. You cannot drop it. -
pg_catalog: Holds the PostgreSQL system catalogs, such aspg_classandpg_type. -
information_schema: Holds the information schema views over database object metadata. -
system: Holds the system virtual tables, such assystem.iceberg_tables.
You can query the objects in pg_catalog, information_schema, and system without naming the schema. You cannot drop these schemas or create objects in them.
Create and manage schemas
Only a superuser can create a schema. In Redpanda Cloud, a user with the SQL: Manage permission is a superuser. A superuser can let other users create views in a schema. To do this, the superuser grants them the USAGE and CREATE privileges on the schema.
| Task | Statement |
|---|---|
Create a schema |
|
Remove a schema |
|
Change the owner of a schema |
|
Let a role use a schema or create views in it |
Search path
When you refer to a view without a schema, Redpanda SQL looks for it in the schemas on the search path. To show or change the search path, see SET/SHOW.