【发布时间】:2022-12-11 18:37:03
【问题描述】:
我想将我创建的用于测试的文件传输到 postgresql 文件,我用命令做到了这一点:psql -h localhost -d test -U postgres -f C:\test1.sql 它给了我这样的错误:
`ERROR: Syntax error in place " ' "
LINE 1: INSERT INTO `test1` (`idcustomer`, `testid`, `customername`, `custlastname`, `birthid...`
我的代码:
`-- phpMyAdmin SQL
-- version 5.2.0
-- https://www.phpmyadmin.net/
--
-- Host: localhost
-- Generation Time: Nov 22, 2022 at 04:31 PM
-- Server version: 10.4.25-MariaDB
-- PHP Version: 8.1.10
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `data`
--
-- --------------------------------------------------------
--
-- Table structure for table `test1`
--
CREATE TABLE `test1` (
`idcustomer` int(5) NOT NULL,
`testid` varchar(250) DEFAULT NULL,
`customername` varchar(250) DEFAULT NULL,
`custlastname` varchar(250) DEFAULT NULL,
`birthid` varchar(250) DEFAULT NULL,
`name` varchar(250) DEFAULT NULL,
`namee` varchar(250) DEFAULT NULL,
`named` varchar(250) DEFAULT NULL,
`phonenumber` varchar(250) DEFAULT NULL,
`testname` varchar(250) DEFAULT NULL,
`testnumber` varchar(250) DEFAULT NULL,
`testnamee` varchar(250) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
--
-- data for table `test1`
--
INSERT INTO 'test1' (`idcustomer`, `testid`, `customername`, `custlastname`, `birthid`, `name`, `namee`, `named`, `phonenumber`, `testname`, `testnumber`, `testnamee`) VALUES
(1, '45645', 'jack', 'xxx', '151', 'nameeeee', 'testtt', 'xname', '585', 'xdname', '985', 'xs'),
(2, '44524', 'adam', 'testt', '525', 'nameee', 'testttt', 'yname', '568', 'xdname', '854', 'xb'),`
如何将此文件导入 postgresql?我为收到这样的错误而疯狂。
我怎么解决这个问题?
【问题讨论】:
-
好吧,PostgreSQL 不支持 MySQL 使用的非标准语法。您需要手动修复该脚本以符合 MySQL 语法
-
我应该修理什么?
-
对于初学者:去掉非标准的反引号。删除 CREATE TABLE 语句中的 SET 语句和“引擎”部分。
-
哦,我想我明白了,你能通过更正我要更改的地方来重新发布代码吗?对不起,我刚开始:(
-
你能帮我编辑我的代码并回复吗?请..请... @a_horse_with_no_name
标签: sql postgresql