码迷,mamicode.com
首页 > 其他好文 > 详细

plaql高级查询命令

时间:2017-04-19 12:46:08      阅读:240      评论:0      收藏:0      [点我收藏+]

标签:use   null   comm   set   student   user   排序   value   var   

一.DDL数据定义语言:表操作
    1.新建表
        SQL> create table good(id number,name varchar2(10));
        
        添加注释
        SQL> comment on table good is ‘商品数据‘;
        SQL> comment on table good.id is ‘商品id‘;
    
    2.删除表
        SQL> drop table students;

    3.改动表
        a.改表结构
            SQL> alter table student drop column gender;
        b.改表名字
            SQL> alter table  student rename to students;
        c.添加约束
            SQL> alter table good add primary key(id);
            SQL> alter table student modify age not null;

    4.查看表
        SQL> select table_name from user_tables;
        SQL> desc student;

二.DML数据操纵语言:表数据操作
    1.增数据
        SQL> insert into good values(1,‘aaa‘,2.0);
        
        如果是从其他表添加,追加select

    2.删数据
        SQL> delete from good where id=1;

    3.改数据
        SQL> update good set price=5.0 where id=2;

    4.查数据
        SQL> select * from good;

        a.排序查找
            SQL> select * from good order by price;

        b.输出显示优化
            SQL> select ‘0‘||id as "编号",name as "名字",price as "价格" from good ;

        c.指定查找
            SQL> select * from good where price in(2);

        d.范围查找
            SQL> select * from good  where price between 1 and 3;

        e.模糊查找
            SQL> select * from good where name like ‘%b‘;

 

plaql高级查询命令

标签:use   null   comm   set   student   user   排序   value   var   

原文地址:http://www.cnblogs.com/hackxiyu/p/6732837.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!