informix dbaccess 常用执行方式及常见技巧
假设:
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 常用执行方式及常见技巧的更多相关文章
- python常用执行方式&变量&input函数
linux系统中执行py文件方式: ./a.py 需要执行权限 chmod -R 777(最大权限) 常用执行方式: 1. ./a.py2. python a.py 文件内部头加上 #!/usr/b ...
- shell脚本的常用执行方式
1.sh+脚本的相对路径 [jinghang@hadoop101 datas]$ sh helloworld.sh helloworld sh+脚本的绝对路径 [jinghang@hadoop101 ...
- iOS代码加密常用加密方式
iOS代码加密常用加密方式 iOS代码加密常用加密方式,常见的iOS代码加密常用加密方式算法包括MD5加密.AES加密.BASE64加密,三大算法iOS代码加密是如何进行加密的,且看下文 MD5 iO ...
- 找到你的位置(JS在页面中的位置)最常用的方式是在页面中head部分放置<script>元素,浏览器解析head部分就会执行这个代码,然后才解析页面的其余部分
找到你的位置(JS在页面中的位置) 我们可以将JavaScript代码放在html文件中任何位置,但是我们一般放在网页的head或者body部分. 放在<head>部分 最常用的方式是在页 ...
- python基础===Python 代码优化常见技巧
Python 代码优化常见技巧 代码优化能够让程序运行更快,它是在不改变程序运行结果的情况下使得程序的运行效率更高,根据 80/20 原则,实现程序的重构.优化.扩展以及文档相关的事情通常需要消耗 8 ...
- 「持续集成实践系列 」Jenkins 2.x 构建CI自动化流水线常见技巧
在上一篇文章中,我们介绍了Jenkins 2.x实现流水线的两种语法,以及在实际工作中该如何选择脚本式语法或声明式语法.原文可查阅:「持续集成实践系列」Jenkins 2.x 搭建CI需要掌握的硬核要 ...
- MySQL DDL执行方式-Online DDL介绍
1 引言 大家好,今天与大家一起分享一下 mysql DDL执行方式. 一般来说MySQL分为DDL(定义)和DML(操作). DDL:Data Definition Language,即数据定义语言 ...
- jQuery中ajax的4种常用请求方式
jQuery中ajax的4种常用请求方式: 1.$.ajax()返回其创建的 XMLHttpRequest 对象. $.ajax() 只有一个参数:参数 key/value 对象,包含各配置及回调函数 ...
- DataGridView 中添加CheckBox和常用处理方式 .
DataGridView 中添加CheckBox和常用处理方式 文章1 转载:http://blog.csdn.net/pinkey1987/article/details/5267934 DataG ...
随机推荐
- 转载 Servlet3.0中使用注解配置Servle
转载地址:http://www.108js.com/article/article10/a0021.html?id=1496 开发Servlet3的程序需要一定的环境支持.Servlet3是Java ...
- Android动画的实现原理 .
1.动画运行模式 独行模式 中断模式 2.Animation类 每个动画都重载了父类的applyTransformation方法这个方法的主要作用是把一些属性组装成一个Transformation类, ...
- SDK开发断点失效
做SDK开发,一般会创建一个静态库工程,然后添加一个app的Target 可是,Xcode7创建的工程,app的Target中断点有效,能断住,为什么静态库的Target中的断点断不住呀. 断点断住发 ...
- 多进程、协程、事件驱动及select poll epoll
目录 -多线程使用场景 -多进程 --简单的一个多进程例子 --进程间数据的交互实现方法 ---通过Queues和Pipe可以实现进程间数据的传递,但是不能实现数据的共享 ---Queues ---P ...
- AngularJS Best Practices: SEO
Google can execute AJAX & JavaScript for indexing, you can read the below link for more detailed ...
- (喷血分享)利用.NET生成数据库表的创建脚本,类似SqlServer编写表的CREATE语句
(喷血分享)利用.NET生成数据库表的创建脚本,类似SqlServer编写表的CREATE语句 在我们RDIFramework.NET代码生成器中,有这样一个应用,就是通过数据库表自动生成表的CREA ...
- 如何快速建立一个测试资源Web服务器及异步获取资源(Unity3D)
背景 1.最近看了几位专栏作家的文章,几篇提到了资源通过网络的动态获取.如何建立一个快速的测试环境,不免是一个问题,也就最简单的就是假设http服务器了,微软系的当然首选的IIS了,别的也能用阿帕奇或 ...
- Unicode、UTF-8、UTF-16和UTF-32的区别
Unicode是一个巨大的字符集,给世界上所有的字符定义了一个唯一编码.其仅仅规定了每个符号的二进制代码,没有制定细化的存储规则.UTF-8.UTF-16.UTF-32才是Unicode的存储格式定义 ...
- Redis常见用法
using ServiceStack.Redis;using System;using System.Collections.Generic;using System.Linq;using Syste ...
- MySQL中select * for update锁表的问题
MySQL中select * for update锁表的问题 由于InnoDB预设是Row-Level Lock,所以只有「明确」的指定主键,MySQL才会执行Row lock (只锁住被选取的资料例 ...