oracle中怎样将字段建成象SQL2000中的ID自动+1的字段
两种方法 方法一: 用触发器 建一个序列 create sequence a_seq increment by 1 start with 100; 建一个触发器, 自动+1 create or replace trigger your_seq_tri before insert on your_table1 for each row declare next_id number; begin select your_seq.nextval into next_id from dual; :new.id := next_id; end; 方法二: 建一个序列 create sequence
Oracle 监控 T-SQL
1. 监控事例的等待 select event,sum(decode(wait_Time,0,0,1)) "Prev", sum(decode(wait_Time,0,1,0)) "Curr",count(*) "Tot" from v$session_Wait group by event order by 4; [@more@] 2. 回滚段的争用情况 select name, waits, gets, waits/gets "Ratio" from v$rollstat a, v$rollname b where a.usn = b.usn; 3. 监控表空间的 I/O 比例 select df.tablespace_name name,df.file_name "file",f.phyrds pyr, f.
PostgreSQL Dynamic SQL & Quote_ident Gotchas
PostgreSQL provides two useful functions to aid in the safe development of dynamic SQL:quote_identThe quote_ident function accepts and returns a text type. Whatever text you pass into quote_ident will be suitably escaped such that you could safely use it as an identifier within a dynamic SQL statement.According to the documentation, you should always pass table and column identifiers into the quote_ident function for safety. Calling quote_ident('mytable') will return mytable, however calling quo
通过ODBC连接Postgresql
适用于: RedHat/SuSE Linux: Version 6.x Applix: Version 5.0 Postgresql: Version 6.5.3 以下的安装的大纲是安装Postgresql在RedHat或者SuSE Linux所必须的. 为了更新Postgresql和更一步的参考资料,请访问www.postgresql.org . 为了完整考虑, 这个文挡解释怎样编译原始资料Applixware安装在 /opt/applix Postgresql 安装在/usr/local/Postgresql 。 你用"root"用户登陆: [@more@]1. 下载Postgresql A."ftp://ftp.postgresql.org/pub/" B. 下载并保存为"postgresql-6.
一个PostgreSQL存储过程的例子
需求: 给出如下条件进行批处理编排 - 开始日期时间 - 重复间隔(分钟) - 重复次数 要求在档期内重复安排节目播出, 比如: 2003.01.01 08:00 开始每隔240分钟播出一次, 一共播出100次 数据库表格(CO_SCHEDULE) ------------------------------ N_PROGID INT DT_STARTTIME TIMESTAMP DT_ENDTIME TIMESTAMP[@more@]存储过程的实现: create table co_schedule(n_progid int,dt_starttime timestamp,dt_endtime time
在Linux下安装和使用MySQL
一、引言 想使用Linux已经很长时间了,由于没有硬性任务一直也没有系统学习,近日由于工作需要必须使用Linux下的MySQL。本以为有Windows下 使用SQL Server的经验,觉得在Linux下安装MySql应该是易如反掌的事,可在真正安装和使用MySQL时走了很多弯路,遇见很多问题,毕竟Linux 和Windows本身就有很大区别。为了让和我一样的初学者在学习的过程中少走弯路,尽快入门,写了此文,希望对您有所帮助。本文的Linux环境是 Red Hat 9.0,MySQL是4.0.16。[@more@] 二、安装Mysql 1、下载MySQL的安装文件 安装MySQL需要
SQL Server的数据导入MySQL数据库方法简介
本文介绍将存放在sql server数据库中的数据全部导入到mysql数据库中的两种方法。[@more@]第一种是安装mysql ODBC,利用sql server的导出功能,选择mysql数据源,进行数据的直接导出,这种方法很简便,但是针对实际应用有很多弊端,最主要体现就是数据类型问题,首先, sql server数据库中的ntext,image等数据类型的数据无法直接写入到mysql数据库中,据说只要稍加改动就可以,可惜偶这只菜鸟还没想到如何 改动,其次,因为偶在mysql中的数据库设计中将时间都设成int型(保存的是时间戳),所以在数据导过来后,就会出现冲突,再次,这种
MySQL 5.0 新特性
Introduction 简介 MySQL 5.0 新特性教程是为需要了解5.0版本新特性的MySQL老用户而写的。简单的来说是介绍了“存储过程、触发器、视图、信息架构视图”,我打算每天一部分,来 连载这个教程.如果你想看一次看完PDF版本的教程,请到down.phpv.net下载.在此感谢译者陈朋奕的努力. 希望这本书能像内行专家那样与您进行对话,用简单的问题、例子让你学到需要的知识。为了达到这样的目的,我会从每一个细节开始慢慢的为大家建立概念,最后会给大家展示较大的实用例,在学习之前也许大家会认为这个用例很难,但是只要跟着课程去学,相信很快就
Oracle和MS SQL server的函数对比
Oracle和MS SQL server的函数对比[@more@]---------数学函数 1.绝对值 S:select abs(-1) value O:select abs(-1) value from dual 2.取整(大) S:select ceiling(-1.001) value O:select ceil(-1.001) value from dual 3.取整(小) S:select floor(-1.001) value O:select floor(-1.001) value from dual 4.取整(截取) S:select cast(-1.002 as int) value O:select trunc(-1.002) value from dual 5.四舍五入 S:select round(1.23456,4