随笔分类 - MySQL Oracle Sql Server
摘要:drop table zrjReinUnClaimTmpT; create table zrjReinUnClaimTmpT ( mainid SERIAL not null, RepayNo varchar(25) not null, comCode varchar(8) not null, CaseNo varchar(25) not null, reinsType varcha...
阅读全文
摘要:Informix 日期类型 datetime year to second 格式为 2003-08-05 10:00:00 datetime year to day 格式为 2003-08-05 Informix 数据类型说明在定义一个字段时,使用char(x)后。如果字段放入的内容不足x长,就会以空格填充,在代码操作时,需要trim()去掉多佘的空格,sql server 2005 也有以上情况。varchar(x) ,x 的最大值是255, 所以它存放的数据是有限的。这个时候,就需要使用lvarcahr(x) ,版本9.4以后可以加长度 x, 那么在hibernate 中怎么映射并使用lv
阅读全文
摘要:/* PL/SQL : Oracle内部语言 SQLServer的是:TSQL Procedural Language/SQL 是oracle在标准的SQL语言上的扩展,PL/SQL不仅允许嵌入SQL语言,还可以 定义变量和常量,允许使用条件语句和循环语句,允许使用例外处理各种错误,这样使得它的功能变得 更加的强大. 优点:提高应用程序的运行性能,模块化的设计思想,减少网络传输量,提高安全性 SQL语言:有两种SQL1992/SQL1996 没有循环控制结构 PL/SQL块由三个部分组成:定义部分,执行部分,例外处理部分 d...
阅读全文
摘要:/* 游标 cursor */
declare cursor c is --声明游标时并不从数据库查询数据 select * from emp ; v_emp c%rowtype;
begin open c; --open游标才真正的查询数据保存到内存 loop fetch c into v_emp; exit when (c%notfound); dbms_output.put_line(v_emp.ename); end loop; close c; --关闭游标
end;
/ declare cursor c ...
阅读全文
摘要:--本周记录SELECT * FROM "jeecms"."dbo"."ORDER_INFO" WHERE datediff(week,O_I_G_DATE,getdate())=0--本月记录 SELECT * FROM "jeecms"."dbo"."ORDER_INFO" WHERE datediff(month,O_I_G_DATE,getdate())=0 -- 最近三个月select * From "jeecms"."dbo"
阅读全文
摘要:数据表结构if exists(select * from sysobjects where name='stuInfo')
drop table stuInfo
create table stuInfo /*创建学员信息表**/
( stuName varchar(20) not null,-- 姓名,非空 stuNo char(6) not null,-- 学号,非空 stuAge int not null,-- 年齡,int 默认为4个长度 stuId numeric(18,0), stuSeat smallint ,-- 坐位 stuAddress text -- 住址
阅读全文
摘要:use master
go
if exists(select * from sysdatabases where name ='stuDB')
drop database stuDB
create database stuDB on primary
( name='stuDB_data',--主数据文件的逻辑名 filename='E:\project\stuDB_data.mdf',--文件物理名 size=5mb, maxsize=100mb,-- 数据文件增长的最大值 filegrowth=15%
)
log on
( name='
阅读全文
摘要:SQL> create table a(id number,name varchar2(20)); Table created
SQL> create sequence seq_a_id start with 1 increment by 1; Sequence created
SQL> create or replace trigger tr_a 2 before insert on a 3 for each row 4 begin 5 select seq_a_id.nextval into :new.id from dual; 6 end; ...
阅读全文
摘要:经典的sql语句保存select case 4-2 when 1 then 'one' when 2 then 'two' else 'more' end;select T.MediaCode,T.MediaName,sum(1) as total,sum(case T.state when 1 then 0 else 1 end) as '未处理', --如果T.state ==1 就统计为0 个数否则统计为1的个数sum(case T.state when 1 then 1 else 0 end) as '已提交
阅读全文
摘要:1.查看当前会话隔离级别select @@tx_isolation;2.查看系统当前隔离级别select @@global.tx_isolation;3.查看当前数据库本版4.设置当前会话隔离级别set session transaction isolatin level repeatable read;5.设置系统当前隔离级别set global transaction isolation level repeatable read;6.命令行,开始事务时set autocommit=off 或者 start transaction7. 查看MySQL 支持的引擎8. 查看当前默认引擎9.
阅读全文