用来返回查询的行数。当指定distinct时,不能接order_by_clause;
如果指定表达式,count返回表达式不为空的值;
当指定*号时,它返回所有行,含重复行和空值。count从不返回null;
count(*) 与 count(1) 执行结果相同,但1并不是指第一列。列名为参数时,查的是不含NULL值的行数;Aggregate Examples (聚合)-- 含重复行和空值,所有行
SELECT COUNT(*) "Total" FROM employees;
SELECT COUNT(1) "Total" FROM employees;Total
-...
sql server中,返回影响行数是:If @@RowCount<1 Oracle中,返回影响行数是:If sql%rowcount<1 例:sqlserver:createprocedure Proc_test@Statint=0,@MsgIdvarchar(50)=‘‘,
ASBEGINUpdate T_Mt Set Stat=@Stat,OStat=@Stat,RptTime=Getdate() Where MsgId=@MsgIdIf@@RowCount<1--没有更新成功就插入到t_Statbuf insertinto t_statbuf(MsgId,Stat,RptTime) values(@MsgId,@Stat,Getdate())
ENDoracle:CREA...
SQL> conn / as sysdba; --DBA登录SQL> alter user scott account unlock;
--解锁SQL> conn scott/tiger;......提示修改新密码SQL> conn scott/xxx; --新密码登录已连接。原文:http://www.cnblogs.com/minamoto/p/3536180.html
exp 导出环境:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
SQL> select * from nls_database_parameters where parameter=‘NLS_CHARACTERSET‘;
PARAMETER VALUE------------------ ----------NLS_CHARACTERSET ZHS16GBK
imp 导入环境:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
SQL> select * from nls_database_parameters where parameter=‘...
r_emp scott.emp%rowtype;cursor cur_emp isselect t.* from scott.emp t;beginopen cur_emp;if cur_emp%isopen thendbms_output.put_line(‘is open...‘);end if;loopfetch cur_empinto r_emp;if cur_emp%found thendbms_output.put_line(‘found...‘);end if;if cur_emp%notfound thendbms_output.put_line(‘not found...‘);end if;exit when cur_emp%notfound;dbms_output.put_line(cur_emp%rowcount || ‘ -> ‘ || r_emp....
to_date(‘20150106 00:00:00‘ , ‘yyyy-mm-dd hh24:mi:ss‘) +
numtodsinterval (level , ‘minute‘) dt
FROM dual
CONNECT BY level <= 24 * 60
2、左外连接,条件 dt >= begin and dt < end + 1
3、需要截取t.begin 和 t.end到分钟
对于begin , trunc(begin,‘mi‘)
对于end , trunc(end+ numtodsinterval(1, ‘minute‘),‘mi‘)) // trunc( end + 1 ,[format])
4、按分钟聚合统计
结果WITH each...
Following the below steps:
Oracle account is locked
1. Type "Conn /as sysdba" in the sqlplus window;
2. Type "alter user AccountName unlocked. Try to logon again.
Oracle user account logon denied
1. Type "Conn /as sysdba" in the sqlplus window;
2. Type "alter user AccountName identified by NEWPASSWORD.
Oracle account is locked or oracle user account logon denied标签:本文系统来源:http://www....
)与count(*)比较: 如果你的数据表没有主键,那么count(1)比count(*)快 如果有主键的话,那主键(联合主键)作为count的条件也比count(*)要快 如果你的表只有一个字段的话那count(*)就是最快的啦 count(*) count(1) 两者比较。主要还是要count(1)所相对应的数据字段。 如果count(1)是聚索引,id,那肯定是count(1)快。但是差的很小的。 因为count(*),自动会优化指定到那一个字段。所以没必要去count(?),用count(*),sql会...
oracle count 百万级 分页查询记录总数、总条数优化
oracle count 百万级 查询记录总数、总条数优化
最近做一个项目时,做分页时,发现分页查询速度很慢,分页我做的是两次查询,一次是查询总数,一次是查询分页结果
/** 查询总记录数 **/SELECTCOUNT(id) FROMUSER order byid/** 查询结果集 **/
select* from( selectrow_.*,rownum rownum_ from( selectid , user_number,user_name,user_password, sex,Registered_time,last...
procedure Proc_test@Stat int=0,@MsgId varchar(50)=‘‘,
AS
BEGIN Update T_Mt Set Stat=@Stat,OStat=@Stat,RptTime=Getdate() Where MsgId=@MsgId If @@RowCount<1 --没有更新成功就插入到t_Statbuf insert into t_statbuf(MsgId,Stat,RptTime) values(@MsgId,@Stat,Getdate())
END oracle:CREATE OR REPLACE PROCEDURE test AS
BEGIN update MY_TIME_TEST1 set discript = ‘6‘ w...
oracle@oracle234 ~]$ wc -l lottu.txt
76761 lottu.txt
[oracle@oracle234 ~]$ head lottu.txt
stat_user_stay_info.rowkey,stat_user_stay_info.appkey,stat_user_stay_info.phone_softversion,stat_user_stay_info.dim_type,stat_user_stay_info.dim_code,stat_user_stay_info.time_peroid,stat_user_stay_info.stat_date,stat_user_stay_info.indicator,stat_user_stay_info.stat_time,stat_user_stay_info.val...
1、如果你的数据表没有主键,那么count(1)比count(*)快2、如果有主键的话,那主键(联合主键)作为count的条件也比count(*)要快3、如果你的表只有一个字段的话那count(*)就是最快的啦4、count(*) count(1) 两者比较。主要还是要count(1)所相对应的数据字段。5、如果count(1)是聚索引,id,那肯定是count(1)快。但是差的很小的。 因为count(*),自动会优化指定到那一个字段。所以没必要去count(?),用count(*),sql会帮你完成优化的
2)...
解除scott账户的锁定方法
1、打开命令提示符(开始菜单输入cmd,回车)2、依次输入如下语句
sqlplus /nolog
conn /as sysdba
alter user scott account unlock;最后会提示解锁成功。Oracle账户被锁解决:ora-28000:the account is locked标签:lock tar hid get acl 点击 开始菜单 锁定 依次 本文系统来源:https://www.cnblogs.com/CodingAndRiding/p/8119577.html
1 --查询数据
2 select * from kk_create_ka where auto_id=‘D7313B4716AD4062B82D3CD8513DA7A8‘;1 --count
2 select count(I_E_Flag) from kk_create_ka where auto_id=‘D7313B4716AD4062B82D3CD8513DA7A8‘;
3 select count(*) from kk_create_ka where auto_id=‘D7313B4716AD4062B82D3CD8513DA7A8‘;
4 select count(1) from kk_create_ka where auto_id=‘D7313B4716AD4062B82D3CD8513DA7A8‘;对应显示结果:
推荐使用...
|| 就是连接两个字段的连接符,所以count(distinct( 字段A || 字段B))就是计算A+B字段唯一的数据行数,即,实现了distinct 多个字段的目的
说明:distinct()部分要放到select与from之间的首个显示字段位置。
||的用法可看我的这篇随笔的链接:https://www.cnblogs.com/Formulate0303/p/12462282.htmlOracle-count(distinct( 字段A || 字段B)) distinct多个字段标签:com html 说明 form sel 连接符 sele 多个...