java:Review(Oracle-HTML-CSS)

20170708_review:


1.oracle:
  对表的操作
    使用命令行建立一张表:create table 表名 (列名 列名的类型 primarty key, ....);
    alter table 表名 add constraints pk_表名_列名 primary key(需要建立的主键列名);
    删除一张表:drop table 表名;
    truncate(清空表中的数据,但是表不被删除)
    修改一张表:alter table 表名(....);
    查询一张表:desc 表名;

  对数据的操作:
    查询:select * from 表名;
    删除:delete from 表名;
    修改:update 表名 set 列名=列名对应的值, ....;----> update teacher set id = 1, name = '张三' where id=4;
    新增:insert into 表名 (列名1,列名2,列名3,....) values(列名对应的值);(values中的值必须要列名顺序对应)
    insert into teacher (id,name,age) values(1,'zhangsan', 29);

  多表查询(简单):
    select * from 表名1,表名2;----->select * from 表名1 t1,表名2 t2 where t1.列名 = 'xxxx';(select * from teacher t, students s where                        t.id=5/ where t.id = s.id)------> 把需要显示的数据查询出来
               select t.name, s.name, t.age, .... from teacher t, students s;----->针对列取一个别名(as),as通常情况下可以省略
     select t.name teacher_name, t.age teacher_age, s.name student_name from teacher, students;

  子查询:
    in(范围):select * from teacher where id in(1,2,3,4,5,...);

               (前提条件是:查询出姓名为张三的学生id,通过这个id找到id相等的老师相关信息)and(并且)/or(或者): select * from teacher where                  id = (select id from students where name = 'zhangsan');------>年龄必须为35岁
               select * from teacher where id = (select id from students where name = 'zhangsan') and age = 35;---->
               或者年龄为35岁select * from teacher where id = (select id from students where name = 'zhangsan') or age = 35;

 

 

    any(任何一个进行匹配) select * from teacher where id > any(select id from students);
    all(所有进行匹配) select * from teacher where id > all (select id from students);

 

 

  函数:
    group by(分组--->group by后的字段,必须要出现在select关键字后面,也就是必须要查询出来): select age from teacher group by                  age;--->group by一般配合count来使用(分组后,每一组数据条数) select name, count(1) counts from teacher group by name;---->分                组函数可以配合where使用,但是必须要放在where关键字后面
               select name from teacher where id > 2 group by name;---->分组以后再进行过滤(having),必须要放在group by的后面,就相当于                 where关键字 select name from teacher group by name having id >3;

 

  聚合函数:
    max,sum,min,**avg(平均值)

    max:select max(salary) max_salary from teacher where id > 2;
    min:select min(salary) max_salary from teacher where id > 2;
    sum:select sum(salary) sum_salary from teacher;
    avg(数据类型必须要为number):select avg(age) from teacher;---->如果使用平均值会出现小数的存在
    ceil(向上取整),floor(向下取整),round(四舍五入) select round(avg(age)) from teacher;---->
    如果age列中的数据有null值(nvl(param1,param2)) select round(avg(nvl(age,0))) from teacher;

 


  日期函数:SimeDateFormat:
    sysdate:系统当前日期(服务器的当前日期)

    to_date(,'yyyy-mm-dd hh:mi:ss'):hh代表12小时制---->to_date(,'yyyy-mm-dd 24hh:mi:ss'):hh就代表了24小时制
    把日期格式的字符串转换为日期格式

    to_char(,'yyyy-mm-dd hh:mi:ss'):
    把日期转换为日期格式的字符串

    *order by(给查询出的数据结果集进行排序,默认是升须asc):
    select * from teacher order by age desc;(降序)
    如果order by和where语句连用-->order by必须要放到where的后面
    如果order by和 group by连用--->order by必须要放到group by的后面
    三个一起连用:where group by (having) order by;


  连接查询
    full join(全连接):不以任何一张表为基准,把所有数据全部查询出

    **inner join(内连接,inner可以省略):只有两张表数据对应的时候才查询出,如果一方没有数据就不显示

    **left join(左连接):以左表为基准关联右表,如果左表没有数据就不显示,如果右表没有数据就显示为一行null

    **right join(右连接):和左连接原理一样,只是以右表为基准

    cross join(交叉连接):<====>select * from teacher, students;

    natural join(自然连接,两张表的列名最多只能有一个相等):和全连接类似;

 

  表之间的关系:(hibernate相关):
    一对一:两张表一一对应(身份证号和个人);
    一对多:其中一张表的一条数据,可以对应另外一张表的多条数据(用户和订单);
    多对多(存在三张表):两张表相互映射,关系表既没有主键又没有外键(列:分别放的是两张表的id)(商品和订单)

  事务:
    transaction
    是把oracle数据一致性转换为另一种数据一致性
    只有增删改才会开启事务

  状态
    提交:把改变的数据永久保存
    回滚:撤销,把数据恢复到未改变前的状态

  分页:
    oracle:
    teacher为例:(以每5条数据为一页)
    select t2.*, rownum as rm2 from (select t1.*, rownum as rm1 from (select * from teacher) t1 where rownum <=5n) t2 where t2.rm1                    >= 5n-4; sql中的5代表每页显示的条数,n代表当前的页数,4代表每页显示的条数-1
    mysql:
    limit:有两个参数,第一个参数代表了当前页面的第一条数据的下标(如果是第一页从0开始),第二个参数代表每页显示的条数

 

 

 

  jdbc:
    // 所有都要java.sql的包
    // 导入驱动jar
    // 加载驱动(反射技术)
    Class.forName("oralce.jdbc.driver.OracleDriver");
    // 获取连接
    Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost/127.0.0.1:1521:orcl","数据库的用户名","密码");
    // 获取预编译的preparedstatement

    PreparedStatement ps = conn.prepareStatement("select * from teacher");
    // 执行sql语句
    // 如果是查询
    ResultSet rs = ps.executeQuery();
    / 遍历结果集
    // 定义一个List集合来接收查询出的结果集
    List<Teacher> list = new ArrayList<Teacher>();
    while(rs.next()) {
    // 创建一个封装的Teacher对象
    Teahcer teacher = new Teacher();
    teacher.setId(rs.getInt("id"));
    teacher.setName(rs.getString("name"));
    teacher.setAge(rs.getString("age"));
    list.add(teacher);
    }
    // 如果为查询,就可以不释放资源,也就是可以不调用close方法

 

 

 


    // 如果是增删改
    // 返回的int类型就代表了受影响的行数
    String sql = "insert into teacher(id, name, age) values(?,?,?)";
    PreparedStatement ps = conn.prepareStatement(sql);
    ps.setString(1,"1");
    rs.setString(2,"zhangsan");
    ps.setInt(3, 32);
    int result = ps.executeUpdate();
    if(result > 0) {
    //操作成功
    } else {
    // 操作失败
    }
    // 释放资源顺序:释放结果集--->然后释放预编译的statement--->最后释放连接
    if(rs != null) {

    }
    if(ps != null) {

    }
    if(conn != null) {

    }

 


  jdbc的封装:
    提取出不常修改的参数:
    private static fianl String DRIVER="";
    private static final String URL = "";
    private static final String USERNAME= "";
    private static final String PASSWORD = "";
    private Connection conn = null;
    private PreparedStatement ps = null;
    public ResultSet rs = null;

    // 所有都要java.sql的包
    // 导入驱动jar
    // 加载驱动(反射技术)


    // 开始封装
    //获取连接的方法
    private void getConnection() {
    Class.forName(DRIVER);
    // 获取连接
    conn = DriverManager.getConnection(URL,USERNAME,PASSWORD);// 给conn赋值
    }

   

 

   // 释放资源的方法
    public void closeAll() {
    if(rs != null) {

    }
    if(ps != null) {

    }
    if(conn != null) {

    }
    }

   

   // 如果是查询
    public ResultSet executeQuery(String sql, String[] pramas) {
    getConnection();
    // 获取预编译的preparedstatement
    select * from teacher where id < ? and age = ?;
    ps = conn.prepareStatement(sql);
    if(pramas != null && pramas.length > 0) {
    ps.setString(i+1, params[i]);
    }
    }
    // 执行提交sql的时候,一定要放在逻辑判断的外部
    rs = ps.executeQuery();
    return rs;

    }
    //一定不能调用closeAll方法

 

 

 

    // 如果为增删改
    public int executeUpdate(String sql, String[] pramas) {
    getConnection();
    // 获取预编译的preparedstatement
    select * from teacher where id < ? and age = ?;
    ps = conn.prepareStatement(sql);
    if(pramas != null && pramas.length > 0) {
    for(int i = 0; i < params.length; i++) {
    ps.setString(i+1, params[i]);
    }
    }
    // 执行提交sql的时候,一定要放在逻辑判断的外部
    int result = ps.executeUpdate();
    return result;
    // 释放资源
    closeAll();
    }

 

 

 

  mysql和oracle的区别:
    在mysql中如果一个列设置为不能为null,依然可以存入null的值,oracle则不行
    在mysql中如果是字符串,既可以使用单引号也可以使用双引号,在oracle中只能使用单引号

 

 

2.HTML:
    form表单:
      action属性:跳转到某个页面,某一个Java类中
      input:
      type属性:text(文本),password(密码),submit(提交),button(按钮),checkbox(多选框),radio(单选框),reset(重置)
      checkbox:多选框,最常用的地方兴趣爱好
      radio:单选框(配置name属性,把name的值相等分为一组)
      select:下拉列表
      option:每一个下拉选项:<option value="传递的时候需要的值">option所需要显示的值</option>
   

   table(表格):
      thead(设置一个标题):
      tr(代表了每一行)-->th(标题内容)
      tbody(设置了标题对应的内容):
      tr--->td(内容显示的数据)
      <table>
      <thead>
      <tr>
      <th></th>
      </tr>
      </thead>

      <tbody>
      <tr>
      <td></td>
      </tr>
      </tbody>
      </table>

  

 

    ul,ol(列表):
      ul:是无序的列表
      ol:是有序的列表
      <ul>
      <li></li>
      </ul>

      <h1~6></h1~6>标题
      <p></p>段落
      <span></span>
      <img src="" alt="如果图片加载失败,就显示alt中的内容" />
      <a href=""></a>链接标签,href:跳转的地址,跳转到页面,也能跳转到Java类
      <div></div>块,最常用到的是盒子模型-->div+css布局(至今最流行的布局方式)
      <br />换行
      <hr />实线的分割线

 

 

3.css:
      color设置一个字体颜色
      background背景
      border边框
      list-style-type:设置一个列表的样式none,circle,....去掉原点

      a:hover:鼠标悬浮的时候会显示的一种状态
      a:active:当点击的时候显示的一种状态
      a:visited:当点击过后显示的一种状态
      a:link:默认第一次的显示状态
      执行顺序:a:link--->a:hover---->a:visited---->a:active  错或   a:link--->a:visited---->a:hover---->a:active  
      如果顺序错乱,就达不到想实现的效果

      text-decoration:none;去掉下划线,underline加上下划线,through-line:贯穿线
      text-align:设置文本 center:居中
      position:定位 fixed:定位(定位在显示器的某一个固定位置),absolute:绝对定位,active:相对定位
      display:none元素隐藏(不占据任何位置),visibility:hidden:元素隐藏(占据页面的一定位置)
      display:inline-block;强制元素不换行
      display:block;强制元素换行

 

    float(浮动):
      left,right左浮动和右浮动
      margin:外边距(两个相邻元素之间的距离)
      padding:内边距(一个元素包含另一个元素,这两个元素之间的距离(填充))

 

 

  选择器:
      id(每个页面只能出现一次,唯一性),class,标签
      id='div1':#div1
      class="div2":.div2
      div标签:div

    

    子元素选择器:
      div p {

      }
      div>p {

      }

 

    相邻元素选择器:(只能选中和他相邻的后面第一个元素)
      div+p {

      }

 

    后续元素选择器:(选中所有相邻的元素)
      div~p {

      }

 

 

    布局:
      div+css
      <div id="total">
      <div id="header"></div>
      <div id="content"></div>
      <div id="footer"></div>
      </div>

  框架:
    iframe:
      <iframe src="top.html"></iframe>--->把top.html导入到当前页面
      frameboeder:0/no;去掉边框
      width:定义一个宽度
      height:定义一个高度

   

     frameset:不能在body标签中
      <frameset rows="100,*(自适应)">
      <frame src="top.html" name="起了一个别名" />
      <frameset cols="300,*">
      <frame src="left.html" name="left" />
      <frame src="right.html" name="right" />
      </frameset>

      <a href="student_manage.html" target="right"><li>学生管理</li></a>

posted @ 2017-07-08 20:16  咫尺天涯是路人丶  阅读(338)  评论(0编辑  收藏  举报