oracle中的DDL与NULL值

    1.sql语句中的 is null 和 is not null 是测试列值是否为空和非空。is null 对应的是数据库中的值为空,就是没有数据,这里的null不是表里实际的值null。

    比如:

select * from cars  --cars表中的所有记录

 
   
  

select * from cars where carname is null --为空的记录

 
   
   

select * from cars where carname is not null --不为空的记录

    
   
 

   

   2. 数据定义的关键字有create、alter、drop,下面主要说明alter:

    添加新的列:

--alter table tablename add 列名 列类型 
alter table cars add carprice number(10) --没有column关键字

 
   
 

    修改列的类型及约束条件:

--alter table 表名 modify (列名 约束条件) 
alter table cars modify (carname not null) 
alter table cars modify (carname varchar2(50)) 

 

 

    删除列名:

--aleter table 表名 drop column 列名 
alter table cars drop column carprice 

 

 

    对列名重新命名:

alter table cars rename column carprice to car_price 
--oracle是9.2以上才能直接使用 

 

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值