AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / user-37007

x-yuri's questions

Martin Hope
x-yuri
Asked: 2022-02-22 02:49:02 +0800 CST

用户类型的属性 51 类型错误

  • 0

我正在尝试将数据从 csv 文件导入 pg 表。我得到的错误是:

$ psql -U postgres -c "COPY users (first_name) FROM '/users.csv' (FORMAT csv)"
ERROR:  attribute 51 of type users has wrong type
DETAIL:  Table has type integer, but query expects character varying.
CONTEXT:  COPY users, line 1

我怎么知道它是关于哪个属性的?就此而言, INSERT 也失败了:

$ psql -U postgres -c "INSERT INTO users (first_name) VALUES ('first_name')"
ERROR:  attribute 51 of type record has wrong type
DETAIL:  Table has type integer, but query expects character varying.

我试图根据\d users输出和attnum值进行计数:

SELECT a.*
FROM pg_attribute a
    JOIN pg_class c on a.attrelid = c.oid
    JOIN pg_namespace n on c.relnamespace = n.oid
WHERE n.nspname = 'public'
    AND c.relname = 'users'
    AND attnum >= 1
ORDER BY attnum

我正在运行 PostgreSQL 12.7。

postgresql insert
  • 1 个回答
  • 48 Views
Martin Hope
x-yuri
Asked: 2017-11-08 08:59:48 +0800 CST

spatial_ref_sys 中存储了什么?

  • 5

迁移到其他服务器时是否应该复制此表中的数据?

postgresql spatial
  • 1 个回答
  • 5740 Views
Martin Hope
x-yuri
Asked: 2016-12-01 05:51:40 +0800 CST

名称与数据库名称不匹配的角色无法访问数据库

  • 3

角色app可以访问数据库app。但是角色app2不能。我没有看到 roleapp的任何特定特权,并且根据以下内容,它不是所有者\l:

app2=> \l

      Name       |  Owner   | Encoding |   Collate   |    Ctype    |    Access privileges
-----------------+----------+----------+-------------+-------------+--------------------------
 app             | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =Tc/postgres            +
                 |          |          |             |             | postgres=CTc/postgres   +
                 |          |          |             |             | app=CTc/postgres        +
                 |          |          |             |             | app2=CTc/postgres
...

app2=> \dp
                                               Access privileges
 Schema |                    Name                     |   Type   | Access privileges | Column access privileges
--------+---------------------------------------------+----------+-------------------+--------------------------
 public | access_users                                | table    |                   |
 public | access_users_id_seq                         | sequence |                   |
...


app2=> select * from users;
ERROR:  permission denied for relation users

为什么角色app能够访问数据库?我可以检查什么?

postgresql permissions
  • 1 个回答
  • 90 Views
Martin Hope
x-yuri
Asked: 2016-11-18 07:35:31 +0800 CST

哪种 mysql 排序规则适合存储 unicode 字符串?

  • 0

据我所知,它必须是utf8mb4_unicode_ci,但是:

> create table t1 (f1 varchar(255) collate utf8mb4_unicode_ci)
> insert into t1 (f1) values ('?')

我得到的是:

ERROR 1366 (22007) at line 1: Incorrect string value: '\xF0\xA2\x84\x82'
    for column 'f1' at row 1

我要插入数据库的符号是这个。

mysql collation
  • 1 个回答
  • 349 Views
Martin Hope
x-yuri
Asked: 2014-10-17 22:05:32 +0800 CST

mysql的一般日志中的“匿名”是什么意思?

  • 2

在mysql的一般日志中,我看到如下内容:

141017  8:57:31     4 Connect   root@localhost as anonymous on

这个“匿名”是什么意思?我以root@localhost. 我仍然是匿名的,甚至是“匿名”吗?

UPD

$ systemctl stop mysqld
$ rm -f /var/lib/mysql/yuri.log
// enable general log in /etc/mysql/my.cnf
$ systemctl start mysqld
$ mysql -u root -p -BNe 'SELECT USER() HowYouAttemptedToLogin, CURRENT_USER() HowMySQLAllowedYouToLogin;'
Enter password:
root@localhost  root@localhost
$ mysql -u root -p -BNe 'SELECT host, user FROM mysql.user;'
Enter password: 
127.0.0.1   root
::1 root
localhost   hostname
localhost   root
$ cat /var/lib/mysql/yuri.log
/usr/bin/mysqld, Version: 10.0.14-MariaDB-log (MariaDB Server). started with:
Tcp port: 3306  Unix socket: /run/mysqld/mysqld.sock
Time                 Id Command    Argument
141204 19:03:19     3 Connect   UNKNOWN_USER@localhost as anonymous on 
            3 Connect   Access denied for user 'UNKNOWN_USER'@'localhost' (using password: NO)
141204 19:04:55     4 Connect   root@localhost as anonymous on 
            4 Query select @@version_comment limit 1
            4 Query SELECT USER() HowYouAttemptedToLogin, CURRENT_USER() HowMySQLAllowedYouToLogin
            4 Quit  
141204 19:05:47     5 Connect   root@localhost as anonymous on 
            5 Query select @@version_comment limit 1
            5 Query SELECT host, user FROM mysql.user
            5 Quit  
mysql log
  • 1 个回答
  • 8060 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    连接到 PostgreSQL 服务器:致命:主机没有 pg_hba.conf 条目

    • 12 个回答
  • Marko Smith

    如何让sqlplus的输出出现在一行中?

    • 3 个回答
  • Marko Smith

    选择具有最大日期或最晚日期的日期

    • 3 个回答
  • Marko Smith

    如何列出 PostgreSQL 中的所有模式?

    • 4 个回答
  • Marko Smith

    列出指定表的所有列

    • 5 个回答
  • Marko Smith

    如何在不修改我自己的 tnsnames.ora 的情况下使用 sqlplus 连接到位于另一台主机上的 Oracle 数据库

    • 4 个回答
  • Marko Smith

    你如何mysqldump特定的表?

    • 4 个回答
  • Marko Smith

    使用 psql 列出数据库权限

    • 10 个回答
  • Marko Smith

    如何从 PostgreSQL 中的选择查询中将值插入表中?

    • 4 个回答
  • Marko Smith

    如何使用 psql 列出所有数据库和表?

    • 7 个回答
  • Martin Hope
    Jin 连接到 PostgreSQL 服务器:致命:主机没有 pg_hba.conf 条目 2014-12-02 02:54:58 +0800 CST
  • Martin Hope
    Stéphane 如何列出 PostgreSQL 中的所有模式? 2013-04-16 11:19:16 +0800 CST
  • Martin Hope
    Mike Walsh 为什么事务日志不断增长或空间不足? 2012-12-05 18:11:22 +0800 CST
  • Martin Hope
    Stephane Rolland 列出指定表的所有列 2012-08-14 04:44:44 +0800 CST
  • Martin Hope
    haxney MySQL 能否合理地对数十亿行执行查询? 2012-07-03 11:36:13 +0800 CST
  • Martin Hope
    qazwsx 如何监控大型 .sql 文件的导入进度? 2012-05-03 08:54:41 +0800 CST
  • Martin Hope
    markdorison 你如何mysqldump特定的表? 2011-12-17 12:39:37 +0800 CST
  • Martin Hope
    Jonas 如何使用 psql 对 SQL 查询进行计时? 2011-06-04 02:22:54 +0800 CST
  • Martin Hope
    Jonas 如何从 PostgreSQL 中的选择查询中将值插入表中? 2011-05-28 00:33:05 +0800 CST
  • Martin Hope
    Jonas 如何使用 psql 列出所有数据库和表? 2011-02-18 00:45:49 +0800 CST

热门标签

sql-server mysql postgresql sql-server-2014 sql-server-2016 oracle sql-server-2008 database-design query-performance sql-server-2017

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve