informix dbaccess 常用执行方式及常见技巧
2010-02-28 09:59
232 查看
假设:
A.数据库servername: testserver
B.数据库名:testdb
C.SQL脚本文件:
sqlfile.sql
create table test_table(c1 integer);
insert into test_table(c1) values(12);
update test_table set c1=0;
delete test_table where 1=1;
drop table test_table;
sqlfile2.sql
create table test_table(c1 integer);
insert into test_table(c2) values(12);
insert into test_table(c1) values(12);
update test_table set c1=0;
delete test_table where 1=1;
drop table test_table;
一.执行SQL脚本文件方式
1.调用dbaccess执行SQL脚本文件
A.简单执行SQL文件
dbaccess testdb sqlfile.sql 或者 dbaccess testdb@testserver sqlfile.sql
Database selected.
Table created.
1 row(s) inserted.
1 row(s) updated.
1 row(s) deleted.
Table dropped.
Database closed.
B.执行输出打印执行语句及执行结果
dbaccess -e testdb sqlfile.sql
create table test_table(c1 integer);
Table created.
insert into test_table(c1) values(12);
1 row(s) inserted.
update test_table set c1=0;
1 row(s) updated.
delete test_table where 1=1;
1 row(s) deleted.
drop table test_table;
Table dropped.
Database closed.
C.将执行结果重定向到文件(shell: bash)
dbaccess -e testdb sqlfile.sql > output.log > 2&1
cat output.log
create table test_table(c1 integer);
Table created.
insert into test_table(c1) values(12);
1 row(s) inserted.
update test_table set c1=0;
1 row(s) updated.
delete test_table where 1=1;
1 row(s) deleted.
drop table test_table;
Table dropped.
Database closed.
二.交互模式执行语句
dbaccess - -
> database testdb;
Database selected.
> create table test_table(c1 integer);
Table created.
> insert into test_table(c1) values(12);
1 row(s) inserted.
> update test_table set c1=0;
1 row(s) updated.
> delete test_table where 1=1;
1 row(s) deleted.
> drop table test_table;
Table dropped.
>^D
三.菜单模式执行
进入数据库
dbaccess 选择数据库
或者
dbaccess testdb
dbaccess testdb@testserver
按菜单操作执行SQL语句,其中可以使用vi进行脚本文件的编辑
四.几个小技巧
1.执行SQL脚本文件时,当出错时打印详细的错误信息
dbaccess -e -m testdb sqlfile2.sql
Database selected.
create table test_table(c1 integer);
Table created
insert into test_table(c2) values(1212);
217: Column (c2) not found in any table in the query (or SLV is undefined).
Error in line 2
Near character position 26
insert into test_table(c1) values(12);
1 row(s) inserted.
update test_table set c1=0;
1 row(s) updated.
delete test_table where 1=1;
1 row(s) deleted.
drop table test_table;
Table dropped.
Database closed.
2.执行SQL脚本文件时,当出错时打印详细的错误信息并在出现第一个错误时,停止继续执行后续的语句
dbaccess -e -m -a testdb sqlfile2.sql
Database selected.
create table test_table(c1 integer);
Table created.
insert into test_table(c2) values(1212);
217: Column (c2) not found in any table in the query (or SLV is undefined).
Error in line 2
Near character position 26
Database closed.
A.数据库servername: testserver
B.数据库名:testdb
C.SQL脚本文件:
sqlfile.sql
create table test_table(c1 integer);
insert into test_table(c1) values(12);
update test_table set c1=0;
delete test_table where 1=1;
drop table test_table;
sqlfile2.sql
create table test_table(c1 integer);
insert into test_table(c2) values(12);
insert into test_table(c1) values(12);
update test_table set c1=0;
delete test_table where 1=1;
drop table test_table;
一.执行SQL脚本文件方式
1.调用dbaccess执行SQL脚本文件
A.简单执行SQL文件
dbaccess testdb sqlfile.sql 或者 dbaccess testdb@testserver sqlfile.sql
Database selected.
Table created.
1 row(s) inserted.
1 row(s) updated.
1 row(s) deleted.
Table dropped.
Database closed.
B.执行输出打印执行语句及执行结果
dbaccess -e testdb sqlfile.sql
create table test_table(c1 integer);
Table created.
insert into test_table(c1) values(12);
1 row(s) inserted.
update test_table set c1=0;
1 row(s) updated.
delete test_table where 1=1;
1 row(s) deleted.
drop table test_table;
Table dropped.
Database closed.
C.将执行结果重定向到文件(shell: bash)
dbaccess -e testdb sqlfile.sql > output.log > 2&1
cat output.log
create table test_table(c1 integer);
Table created.
insert into test_table(c1) values(12);
1 row(s) inserted.
update test_table set c1=0;
1 row(s) updated.
delete test_table where 1=1;
1 row(s) deleted.
drop table test_table;
Table dropped.
Database closed.
二.交互模式执行语句
dbaccess - -
> database testdb;
Database selected.
> create table test_table(c1 integer);
Table created.
> insert into test_table(c1) values(12);
1 row(s) inserted.
> update test_table set c1=0;
1 row(s) updated.
> delete test_table where 1=1;
1 row(s) deleted.
> drop table test_table;
Table dropped.
>^D
三.菜单模式执行
进入数据库
dbaccess 选择数据库
或者
dbaccess testdb
dbaccess testdb@testserver
按菜单操作执行SQL语句,其中可以使用vi进行脚本文件的编辑
四.几个小技巧
1.执行SQL脚本文件时,当出错时打印详细的错误信息
dbaccess -e -m testdb sqlfile2.sql
Database selected.
create table test_table(c1 integer);
Table created
insert into test_table(c2) values(1212);
217: Column (c2) not found in any table in the query (or SLV is undefined).
Error in line 2
Near character position 26
insert into test_table(c1) values(12);
1 row(s) inserted.
update test_table set c1=0;
1 row(s) updated.
delete test_table where 1=1;
1 row(s) deleted.
drop table test_table;
Table dropped.
Database closed.
2.执行SQL脚本文件时,当出错时打印详细的错误信息并在出现第一个错误时,停止继续执行后续的语句
dbaccess -e -m -a testdb sqlfile2.sql
Database selected.
create table test_table(c1 integer);
Table created.
insert into test_table(c2) values(1212);
217: Column (c2) not found in any table in the query (or SLV is undefined).
Error in line 2
Near character position 26
Database closed.
相关文章推荐
- informix dbaccess 常用执行方式及常见技巧
- SQL常用语法+技巧+语句导入导出+常见面试题
- 执行计划中三种最常用连接方式的伪码实现
- ios-day12-01(ios开发中的数据存储的常用方式有哪些、应用沙盒目录结构、应用沙盒目录路径的常见获取方式)
- redis常用命令、常见错误、配置技巧等分享
- redis常用命令、常见错误、配置技巧等分享
- redis常用命令、常见错误、配置技巧等分享
- 神兵利器之Android Studio常用技巧和常见问题
- redis常用命令、常见错误、配置技巧等分享
- Java异步执行任务常用方式FutureTask和ExecutorService
- 中文乱码问题 ? 原因:JSP中默认使用iso-8859-1字符编码方式,不支持中文 ? 常见的支持中文的编码方式:gb2312(常用简体汉字)、gbk(简体和繁体汉字)、utf-8 ? 解决中文乱码
- axis1.4 wsdd 方式发布webservice 服务配置文件以及常用的DOS执行语句
- jQuery 常见操作实现方式和常用函数方法总结
- redis常用命令、常见错误、配置技巧等分享
- jQuery 常见操作实现方式和常用函数方法总结
- 4种PHP异步执行的常用方式
- redis常用命令、常见错误、配置技巧
- js页面跳转常用的几种方式_javascript技巧
- maven项目常用技巧:将依赖打包到文件夹并生产可执行的jar