【问题标题】:Database drop: command not found Informix on Ubuntu数据库删除:在 Ubuntu 上找不到命令 Informix
【发布时间】:2019-07-11 13:24:54
【问题描述】:

我正在尝试运行源代码以使用以下行在 Informix 中编辑数据库: 如果存在表名,则删除表;

但是我收到一条错误消息: 删除:找不到命令

我正在尝试运行源代码以使用以下行在 Informix 中编辑数据库: 如果存在表名,则删除表;

但是我收到一条错误消息: 删除:找不到命令

我是数据库和 Ubuntu 的新手,所以这对我来说不是直截了当的。请帮助如何解决这个问题。谢谢。

#!/bin/bash
export PATH=$PATH:.
#UTC
dt="2016-09-01 00:00:00.00000"
# dt=`date -u +"%Y-%m-%d %H:%M:%S.00000"` 
# non-UTC
# dt=`date +"%Y-%m-%d %H:%M:%S.00000"`

echo ""
echo "Building DB"
dbaccess sysmaster - <<EOF1

drop database if exists iot;
create database iot in datadbs1 with buffered log ; 
EOF1

echo ""
echo "Building row types, tables, and other objects" dbaccess iot - 


drop table if exists sensors;
drop table if exists sensors_vti;
...

【问题讨论】:

  • @Simonare 诊断出正确的问题,您错误地编写了 drop table 命令,因为它们在 echo 之外。上面正确的最后一行是 ` echo "drop table if exists sensors" | dbaccess iot - echo "drop table if exists sensors_vti" | dbaccess iot -` 或它的变体。

标签: bash shell ubuntu informix heredoc


【解决方案1】:

你不能(直接)在 bash 中使用 db 命令

drop table if exists sensors;
drop table if exists sensors_vti;

你需要使用的格式是

dbaccess sysmaster - <<EOF
    drop database if exists iot;
    create database iot in datadbs1 with buffered log ; 
EOF

或者

echo "drop database if exists iot;create database iot in datadbs1 with buffered log ;" | dbaccess sysmaster 

【讨论】:

    猜你喜欢
    • 2013-09-30
    • 2015-02-20
    • 2020-11-27
    • 2014-09-11
    • 1970-01-01
    • 1970-01-01
    • 2020-08-07
    • 2021-05-24
    • 1970-01-01
    相关资源
    最近更新 更多