gpt4 book ai didi

sql - 架构已创建但其中的表无法显示

转载 作者:行者123 更新时间:2023-11-29 11:43:00 25 4
gpt4 key购买 nike

代码如下:

testdb=# create schema myschema1;
CREATE SCHEMA
testdb=# \d
List of relations
Schema | Name | Type | Owner
--------+------------+-------+--------
public | company | table | kaiyin
public | department | table | kaiyin
(2 rows)

testdb=#
testdb=# create table myschema1.company1(
testdb(# ID INT NOT NULL,
testdb(# NAME VARCHAR (20) NOT NULL,
testdb(# AGE INT NOT NULL,
testdb(# ADDRESS CHAR (25) ,
testdb(# SALARY DECIMAL (18, 2),
testdb(# PRIMARY KEY (ID)
testdb(# );
CREATE TABLE
testdb=# \d
List of relations
Schema | Name | Type | Owner
--------+------------+-------+--------
public | company | table | kaiyin
public | department | table | kaiyin
(2 rows)

testdb=# select * from myschema1.company1

什么都没有出现。也许是因为 table 是空的?

testdb=# insert into myschema1.company1 values (1, joyce, 23, amsterdam, 60000, 1)
testdb-# select * from myschema1.company1
testdb-#

仍然没有。为什么?

OS X,postgresql 9.4.4

最佳答案

psql 中的\d 命令使用当前模式搜索列表,默认为public。您需要告诉它搜索您的架构:\d myschema1.*

关于sql - 架构已创建但其中的表无法显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31943417/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com