Plsql

使用逻辑运算符 and   or    not
1.查询出年龄在15—20之间的所有人信息(包含)
select * from user where age>=15 and age<=20;
select * from user where age between 15 and 20;
2.查询出年龄大于15且性别为女的用户信息
select * from user where age>15 and sex='女';
3.查询出年龄大于15岁或者性别为女的用户信息
select * from user where age>15 or sex='女';
4.查询出年龄为15或16或17的用户信息
select * from user where age=15 or age=16 or age=17;
select * from user where age in(15,16,17);
5.查询出年龄不是15岁的用户信息
select * from user where age!=15;// 不等号可以用 != 和 <>
select * from user where not age=15;




使用模糊查询like 
%: 0—n个任意字符
 _: 1个任意字符


1.查询出姓王的用户信息
select * from user where name like '王%';
2.查询出名字中包含王的用户信息


统计数据、记录的条数
select count(*) from 表名 [where 条件];




JDBC连接


Eg://加载MySQL驱动

Class.forName("com.mysql.jdbc.Driver");


Eg://加载Oracle驱动
Class.forName("oracle.jdbc.driver.OracleDriver");


3.发送SQL语句
通过Connection对象获得Statement对象,再使用Statement对象发送SQL语句。


Eg://取得Connection对象
Statement st = conn.createStatement();


Eg://发送SQL语句
ResultSet rs = st.executeQuery("select * from student");//执行查询
int x = st.executeUpdate("delete from student where sex='女'");//执行删除

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值