工作中遇到的Orale的数据结构的操作内容

---------修改表的字段长度示例:-------------

alter table  es_order  modify(payee_account_bank VARCHAR2(150),payee_account_bank_addr VARCHAR2(200));

--------获取查询结果的记录数-----------------

count(1) 与 count(*) 比较【select count(*) from t             select count(1) from t 】

1.如果你的数据表没有主键,那么count(1)比count(*)快,如果有主键的话,那么主键(联合主键)作为count的条件比count(*)快;

2.如果你的表只有一个字段的话那count(*)就是最快的;

3.count(*)将返回表格中所有存在的行的总数包括值为null的行( count(*) 选择整行来统计),然而count(列名)将返回表格中除去null以外的所有行的总数(有默认值的列也会被计入),选择特定字段来统计;

4.count(1) 选择表的第一个字段来统计;

-------添加表字段和注释----------

alter table ns_account_check add (update_cutoff_time date,offset_balance number(19,8),cutoff_time date,customer_id varchar2(14));
comment on column NS_ACCOUNT_CHECK.customer_id is '客户id';
comment on column NS_ACCOUNT_CHECK.update_cutoff_time is '更新时会计日';
comment on column NS_ACCOUNT_CHECK.offset_balance is '账户差额';
comment on column NS_ACCOUNT_CHECK.cutoff_time is '平台日切时间';

 ----------计算总金额--------------

select nvl(sum(a.ST_AMT),0) from ns_bill_biz;

NVL是Oracle PL/SQL中的一个函数。它的格式是NVL( string1, replace_with)。它的功能是如果string1为NULL,则NVL函数返回replace_with的值,否则返回string1的值。

 ---------分组和count--------

select  customer_id,count(customer_id)  from ns_customer_info  group by    customer_id      having   count(customer_id) =1;

 

你可能感兴趣的:(数据结构)