数据库丢弃:在Ubuntu上找不到Informix命令

问题描述 投票:0回答:1

我正在尝试使用以下行运行源代码来编辑Informix中的数据库:drop table if exists tablename;

但是我收到一条错误消息:drop:command not found

我正在尝试使用以下行运行源代码来编辑Informix中的数据库:drop table if exists tablename;

但是我收到一条错误消息:drop:command not found

我是数据库和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;
...
bash shell ubuntu informix heredoc
1个回答
0
投票

你不能在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 
© www.soinside.com 2019 - 2024. All rights reserved.