• Oracle之数据库的增删改查和格式的修改


    Oracle修改数据

    *update语句

    格式:

    update table_name set column1=value1,…[where conditions]

     

    例子:

    update userinfo      set userpwd=“12345” where username=“xxx”;

     

    *删除数据

    create table testdel as select * from userinfo;

     

    delete from testdel;

    #把新表删了

     

    delete from userinfo where username=“yyy”;

    #把指定的人的信息所在的行删除了

     

    基本查询语句

    格式:

    select [distinct] column_name1,…|*

    from table_name

    [where conditions]

     

    说明:其中distinct是表示去掉重复的行。

     

    在SQL*PLUS中设置格式

    *改变字段名

    格式:

    column column_name heading  new_name

    例子:

    col username heading 用户名;

    说明:把user这个字段改为“用户名”;

     

    *改变字段长度

    例子:

    col username format a10;

    #把username这个字段的长度改为10个单位长

    select * from users;

     

    例子:

    col salary format 999.9;

    说明:这表示将该字段的所对应的值设为三位整数

    和一位小数,没有小数则补0,整数位数不足,则会以###显示。

     

    例子:

    col salary format $999.9;

    说明:将该字段的值改为美元格式显示。

     

    格式:

    column column_name clear;

    说明:column可以简写为col,该语法表示将原有格式还原,将现有格式清除。

    col salary clear;

    col salary clear;

     

    Oracle查询语句之给字段设置别名

    例子:

    select id as 编号, username as 用户名,salary

    工资  from users;

    说明:也就是说给字段起别名有两种方式,加上

    前面的format方式。

     

    select distinct username as 用户名

    from users;

    说明:这里是将“用户名”这个字段中的重复的值去掉。

     

    运算符和表达式

    *算术运算符(+-*/)

    *比较运算符(>,>=,<,<=,=,<>)

    说明:省略,自己在网上找例子。

     

    带条件的查询

    *单一条件的查询

    例子:

    select salary 

    from users 

    where username=“sss”;

     

    select * from users 

    where username=“aaa”

    or salary>2000;

     

    select * from users

    where username=“aaa” or

    (salary=800 and salary<=2000);

     

    说明:逻辑运算符的优先级:按not/and/or的

    顺序依次递减。

     

    select * from users  where not(username=“aaa”);

    说明:把”aaa”这个用户除外是所有用户的信息展现出来,自己也试试。

     

     

    模糊查询:

    select * from users

    where name like ‘a%’;

    说明:like位于字段和模糊搜索之间

     

    范围查询:

    between ..and

     

    select * from users where salary between 800 and 2000;

     

    select * from users where salary not between  800 and 2000;

     

    in/not in

    in(一个列表的值)

    select * from users 

    where username in(‘aaa’,’bbb’);

    说明:表示查询用户名是aaa或者是bbb的用户的

    信息。其中的“,”有点像是“或”的意思。

    select * from users 

    where username not in(‘aaa’,’bbb’);

    说明:表示查询用户名是aaa和bbb的用户的

    信息。其中的“,”有点像“且”的意思。

     

     

    PL/SQL developer的使用,多百度一下

    看看视频之类的

     

     

     

     

     

     

     

     

     

    成年人的世界没有那么多的童话,也没有那么多的逆袭。
  • 相关阅读:
    @Autowired和@Resource注解的注入顺序
    八大排序算法(Java实现)+ 自制动画
    一文秒杀三个经典面试求和问题
    这篇文章,或许对还在上学的你,有一些帮助
    得了,一文把前缀和给扒的干干净净了。
    BF,BM,KMP,就这?
    那个贼贵的比特币到底是什么原理?
    小样?别以为你穿了几个马甲就不认得你是二分法!
    面试前必知必会的二分查找及其变种
    Vue.js 官方示例初探
  • 原文地址:https://www.cnblogs.com/shijinglu2018/p/9857818.html
Copyright © 2020-2023  润新知