Skip to content

Commit 2113f5b

Browse files
author
Eric Harmeling
committed
Updated SHOW TABLES and SHOW SCHEMAS output for v20.2.0-beta-4
1 parent 35ed61a commit 2113f5b

18 files changed

+393
-388
lines changed

v20.2/alter-schema.md

+55-49
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Parameter | Description
3131

3232
### Rename a schema
3333

34-
Suppose that you access the [SQL shell](cockroach-sql.html) as user `demo`, and [create a new user](create-user.html) `max` and [a schema](create-schema.html) `org_one` with `max` as the owner:
34+
Suppose that you access the [SQL shell](cockroach-sql.html) as user `root`, and [create a new user](create-user.html) `max` and [a schema](create-schema.html) `org_one` with `max` as the owner:
3535

3636
{% include copy-clipboard.html %}
3737
~~~ sql
@@ -49,14 +49,14 @@ Suppose that you access the [SQL shell](cockroach-sql.html) as user `demo`, and
4949
~~~
5050

5151
~~~
52-
schema_name | owner
53-
---------------------+--------
54-
crdb_internal | NULL
55-
information_schema | NULL
56-
org_one | max
57-
pg_catalog | NULL
58-
pg_extension | NULL
59-
public | admin
52+
schema_name
53+
----------------------
54+
crdb_internal
55+
information_schema
56+
org_one
57+
pg_catalog
58+
pg_extension
59+
public
6060
(6 rows)
6161
~~~
6262

@@ -72,9 +72,9 @@ ERROR: must be owner of schema "org_one"
7272
SQLSTATE: 42501
7373
~~~
7474

75-
Because you are executing the `ALTER SCHEMA` command as a non-owner of the schema (i.e., `demo`), CockroachDB returns an error.
75+
Because you are executing the `ALTER SCHEMA` command as a non-owner of the schema (i.e., `root`), CockroachDB returns an error.
7676

77-
[Drop the schema](drop-schema.html) and create it again, this time with with `demo` as the owner.
77+
[Drop the schema](drop-schema.html) and create it again, this time with with `root` as the owner.
7878

7979
{% include copy-clipboard.html %}
8080
~~~ sql
@@ -86,21 +86,24 @@ Because you are executing the `ALTER SCHEMA` command as a non-owner of the schem
8686
> CREATE SCHEMA org_one;
8787
~~~
8888

89+
To verify that the owner is now `root`, query the [`pg_catalog.pg_namespace` and `pg_catalog.pg_users` tables](sql-name-resolution.html#databases-with-special-names):
90+
8991
{% include copy-clipboard.html %}
9092
~~~ sql
91-
> SHOW SCHEMAS;
93+
> SELECT
94+
nspname, usename
95+
FROM
96+
pg_catalog.pg_namespace
97+
LEFT JOIN pg_catalog.pg_user ON pg_namespace.nspowner = pg_user.usesysid
98+
WHERE
99+
nspname LIKE 'org_one';
92100
~~~
93101

94102
~~~
95-
schema_name | owner
96-
---------------------+--------
97-
crdb_internal | NULL
98-
information_schema | NULL
99-
org_one | demo
100-
pg_catalog | NULL
101-
pg_extension | NULL
102-
public | admin
103-
(6 rows)
103+
nspname | usename
104+
----------+----------
105+
org_one | root
106+
(1 row)
104107
~~~
105108

106109
As its owner, you can rename the schema:
@@ -116,20 +119,20 @@ As its owner, you can rename the schema:
116119
~~~
117120

118121
~~~
119-
schema_name | owner
120-
---------------------+--------
121-
crdb_internal | NULL
122-
information_schema | NULL
123-
org_two | demo
124-
pg_catalog | NULL
125-
pg_extension | NULL
126-
public | admin
122+
schema_name
123+
----------------------
124+
crdb_internal
125+
information_schema
126+
org_two
127+
pg_catalog
128+
pg_extension
129+
public
127130
(6 rows)
128131
~~~
129132

130133
### Change a schema's owner
131134

132-
Suppose that you access the [SQL shell](cockroach-sql.html) as user `demo`, and [create a new schema](create-schema.html) named `org_one`:
135+
Suppose that you access the [SQL shell](cockroach-sql.html) as user `root`, and [create a new schema](create-schema.html) named `org_one`:
133136

134137
{% include copy-clipboard.html %}
135138
~~~ sql
@@ -142,22 +145,22 @@ Suppose that you access the [SQL shell](cockroach-sql.html) as user `demo`, and
142145
~~~
143146

144147
~~~
145-
schema_name | owner
146-
---------------------+--------
147-
crdb_internal | NULL
148-
information_schema | NULL
149-
org_one | demo
150-
pg_catalog | NULL
151-
pg_extension | NULL
152-
public | admin
148+
schema_name
149+
----------------------
150+
crdb_internal
151+
information_schema
152+
org_one
153+
pg_catalog
154+
pg_extension
155+
public
153156
(6 rows)
154157
~~~
155158

156159
Now, suppose that you want to change the owner of the schema `org_one` to an existing user named `max`. To change the owner of a schema, the current owner must belong to the role of the new owner (in this case, `max`), and the new owner must have `CREATE` privileges on the database.
157160

158161
{% include copy-clipboard.html %}
159162
~~~ sql
160-
> GRANT max TO demo;
163+
> GRANT max TO root;
161164
~~~
162165

163166
{% include copy-clipboard.html %}
@@ -170,21 +173,24 @@ Now, suppose that you want to change the owner of the schema `org_one` to an exi
170173
> ALTER SCHEMA org_one OWNER TO max;
171174
~~~
172175

176+
To verify that the owner is now `max`, query the [`pg_catalog.pg_namespace` and `pg_catalog.pg_users` tables](sql-name-resolution.html#databases-with-special-names):
177+
173178
{% include copy-clipboard.html %}
174179
~~~ sql
175-
> SHOW SCHEMAS;
180+
> SELECT
181+
nspname, usename
182+
FROM
183+
pg_catalog.pg_namespace
184+
LEFT JOIN pg_catalog.pg_user ON pg_namespace.nspowner = pg_user.usesysid
185+
WHERE
186+
nspname LIKE 'org_one';
176187
~~~
177188

178189
~~~
179-
schema_name | owner
180-
---------------------+--------
181-
crdb_internal | NULL
182-
information_schema | NULL
183-
org_one | max
184-
pg_catalog | NULL
185-
pg_extension | NULL
186-
public | admin
187-
(6 rows)
190+
nspname | usename
191+
----------+----------
192+
org_one | max
193+
(1 row)
188194
~~~
189195

190196
## See also

v20.2/cockroach-demo.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -266,14 +266,14 @@ By default, `cockroach demo` loads the `movr` dataset in to the demo cluster:
266266
~~~
267267

268268
~~~
269-
schema_name | table_name | type | owner | estimated_row_count
270-
--------------+----------------------------+-------+-------+----------------------
271-
public | promo_codes | table | demo | 0
272-
public | rides | table | demo | 0
273-
public | user_promo_codes | table | demo | 0
274-
public | users | table | demo | 0
275-
public | vehicle_location_histories | table | demo | 0
276-
public | vehicles | table | demo | 0
269+
schema_name | table_name | type | estimated_row_count
270+
--------------+----------------------------+-------+----------------------
271+
public | promo_codes | table | 1000
272+
public | rides | table | 500
273+
public | user_promo_codes | table | 0
274+
public | users | table | 50
275+
public | vehicle_location_histories | table | 1000
276+
public | vehicles | table | 15
277277
(6 rows)
278278
~~~
279279

v20.2/cockroach-gen.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -214,10 +214,10 @@ $ cockroach sql --url='postgres://demo:[email protected]:55531?sslmode=require'
214214
> SHOW TABLES FROM startrek;
215215
~~~
216216
~~~
217-
schema_name | table_name | type | owner | estimated_row_count
218-
--------------+------------+-------+-------+----------------------
219-
public | episodes | table | demo | 79
220-
public | quotes | table | demo | 200
217+
schema_name | table_name | type | estimated_row_count
218+
--------------+------------+-------+----------------------
219+
public | episodes | table | 79
220+
public | quotes | table | 200
221221
(2 rows)
222222
~~~
223223

@@ -252,9 +252,9 @@ $ cockroach sql --url='postgres://demo:[email protected]:55531?sslmode=require'
252252
~~~
253253

254254
~~~
255-
schema_name | table_name | type | owner | estimated_row_count
256-
--------------+------------+-------+-------+----------------------
257-
public | mytable | table | demo | 42
255+
schema_name | table_name | type | estimated_row_count
256+
--------------+------------+-------+----------------------
257+
public | mytable | table | 42
258258
(1 row)
259259
~~~
260260

v20.2/convert-to-schema.md

+26-26
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,14 @@ By default, tables are stored in the `public` schema:
5050
~~~
5151

5252
~~~
53-
schema_name | table_name | type | owner | estimated_row_count
54-
--------------+----------------------------+-------+-------+----------------------
55-
public | promo_codes | table | demo | 1000
56-
public | rides | table | demo | 500
57-
public | user_promo_codes | table | demo | 0
58-
public | users | table | demo | 50
59-
public | vehicle_location_histories | table | demo | 1000
60-
public | vehicles | table | demo | 15
53+
schema_name | table_name | type | estimated_row_count
54+
--------------+----------------------------+-------+----------------------
55+
public | promo_codes | table | 1000
56+
public | rides | table | 500
57+
public | user_promo_codes | table | 0
58+
public | users | table | 50
59+
public | vehicle_location_histories | table | 1000
60+
public | vehicles | table | 15
6161
(6 rows)
6262
~~~
6363

@@ -90,14 +90,14 @@ Convert the `movr` database to a schema, with `cockroach_labs` as its parent dat
9090
~~~
9191

9292
~~~
93-
schema_name | owner
94-
---------------------+--------
95-
crdb_internal | NULL
96-
information_schema | NULL
97-
movr | demo
98-
pg_catalog | NULL
99-
pg_extension | NULL
100-
public | admin
93+
schema_name
94+
----------------------
95+
crdb_internal
96+
information_schema
97+
movr
98+
pg_catalog
99+
pg_extension
100+
public
101101
(6 rows)
102102
~~~
103103

@@ -107,14 +107,14 @@ Convert the `movr` database to a schema, with `cockroach_labs` as its parent dat
107107
~~~
108108

109109
~~~
110-
schema_name | table_name | type | owner | estimated_row_count
111-
--------------+----------------------------+-------+-------+----------------------
112-
movr | promo_codes | table | demo | 1000
113-
movr | rides | table | demo | 500
114-
movr | user_promo_codes | table | demo | 0
115-
movr | users | table | demo | 50
116-
movr | vehicle_location_histories | table | demo | 1000
117-
movr | vehicles | table | demo | 15
110+
schema_name | table_name | type | estimated_row_count
111+
--------------+----------------------------+-------+----------------------
112+
movr | promo_codes | table | 0
113+
movr | rides | table | 0
114+
movr | user_promo_codes | table | 0
115+
movr | users | table | 0
116+
movr | vehicle_location_histories | table | 0
117+
movr | vehicles | table | 0
118118
(6 rows)
119119
~~~
120120

@@ -124,8 +124,8 @@ Convert the `movr` database to a schema, with `cockroach_labs` as its parent dat
124124
~~~
125125

126126
~~~
127-
schema_name | table_name | type | owner | estimated_row_count
128-
--------------+------------+------+-------+----------------------
127+
schema_name | table_name | type | estimated_row_count
128+
--------------+------------+------+----------------------
129129
(0 rows)
130130
~~~
131131

0 commit comments

Comments
 (0)