//創建表格
create table UseInfo
(
userGUID varchar(
32),
useID varchar2(
10),
useName Nvarchar2(
5),
usePWD varchar2(
16),
useEmail varchar2(
50),
usePower integer,
useWriterDate varchar2(
8),
useExportExcel real
);


//修改欄位大小
alter table userinfo
modify ( useName varchar2(
10));


//增加欄位
alter table useinfo
add (useNote varchar2(
50));

//刪除欄位
 alter table useinfo
 drop column userguid;

//增加主鍵
 alter table useinfo
 add constraint useinfo_userGUID_pk
 primary key (useGUID);

//刪除主鍵
alter table  useinfo
drop constraint useinfo_userGUID_pk;
//增加外鍵
 alter table ConcernDetail
 add constraint ConcernDetail_ccdccbGUID_FK
 foreign key(ccdccbGUID) references ConcernBrand(ccbGUID);

orcle常用語句//得到指定行數的資料
orcle常用語句
select * from erpuser.customer where rownum<4;

orcle常用語句//查看所有表
orcle常用語句
 select * from tab;

orcle常用語句//查看約束
orcle常用語句
select owner,constraint_name,constraint_type,table_name from user_constraintsorcle常用語句 where owner='WEBUSER';

orcle常用語句//冊除主鍵
orcle常用語句
alter table brand_customer_lot_detailorcle常用語句drop constraint brand_customer_lot_detail_pk;

orcle常用語句//清除sql plus屏幕
orcle常用語句
clear screen;

  //更新值
1) 最简单的形式
orcle常用語句   
--经确认customers表中所有customer_id小于1000均为'北京'
orcle常用語句   
--1000以内的均是公司走向全国之前的本城市的老客户:)
orcle常用語句   update customers
orcle常用語句   
set    city_name='北京'
orcle常用語句   
where  customer_id<1000
orcle常用語句
orcle常用語句
2) 两表(多表)关联update -- 仅在where字句中的连接
orcle常用語句   
--这次提取的数据都是VIP,且包括新增的,所以顺便更新客户类别
orcle常用語句   update customers  a       
-- 使用别名
orcle常用語句   
set    customer_type='01' --01 为vip,00为普通
orcle常用語句   
where  exists (select 1
orcle常用語句                  from   tmp_cust_city b
orcle常用語句                  
where  b.customer_id=a.customer_id
orcle常用語句                 )
orcle常用語句
orcle常用語句
3) 两表(多表)关联update -- 被修改值由另一个表运算而来
orcle常用語句   update customers a   
-- 使用别名
orcle常用語句   
set    city_name=(select b.city_name from tmp_cust_city b where b.customer_id=a.customer_id)
orcle常用語句   
where  exists (select 1
orcle常用語句                  from   tmp_cust_city b
orcle常用語句                  
where  b.customer_id=a.customer_id
orcle常用語句                 )
orcle常用語句   
-- update 超过2个值
orcle常用語句   update customers a   
-- 使用别名
orcle常用語句   
set    (city_name,customer_type)=(select b.city_name,b.customer_type
orcle常用語句                                     from   tmp_cust_city b
orcle常用語句                                     
where  b.customer_id=a.customer_id)
orcle常用語句   
where  exists (select 1
orcle常用語句                  from   tmp_cust_city b
orcle常用語句                  
where  b.customer_id=a.customer_id
orcle常用語句                 )

   //刪除表
orcle常用語句drop table CONCERNDETAIL;

   //插入資料
   insert into brand_customer_lot
orcle常用語句 values(
'2008010220','A00001','lot_200801020','A1');

  insert into brand_customer_lot_detail
 values('2008010220','CF','Acer',to_date('20080102','yyyy-mm-dd'),'Q',200,200000,'R');

方法:
round()是四舍五入,不是取整。 
ceil()是进一,floor()是去尾,都是返回整数。 
trunc()也是去尾,但是可以指定小数位数,不指定即为取整,所以也是对的。

相关文章:

  • 2021-09-26
  • 2021-09-25
  • 2021-09-07
  • 2021-12-19
  • 2021-12-29
  • 2022-01-13
  • 2021-09-12
  • 2021-09-30
猜你喜欢
  • 2021-11-22
  • 2021-08-21
  • 2021-09-30
  • 2022-01-17
  • 2021-08-12
相关资源
相似解决方案