zoukankan      html  css  js  c++  java
  • jdbc知识问答

    1 JDBC连接数据库6

    1. Load the JDBC Driver
    2. Establish the Database Connection
    3. Create a Statement Object
    4. Execute a Query
    5. Process the Results
    6. Close the Connection

    2 事务的4大特性

    答:原子性A,一致性C,隔离性I,永久性D

    3.select count* from student select countid from student 之间的区别。

    答案:

    select count(*) 统计所有学生的记录个数,包括空记录。

    Select count(Id) 统计所有学生的记录个数,不包括null记录。

    4假设现在有表system.table1,表中有三个字段:id(数值型)name(字符型)、age(数值型)写出SQL语句完成如下功能:在表中查出年龄大于20,且名字以开头的记录,并且按照年龄的倒叙排列出来(年龄大的在前面)。

    答案:

    Select * from system.table1 where age>20 and name like ‘王%’ order by age DESC;

    5 .创建CUSTOMERS表,字段为:ID:(非空,主键)bigintNAME:(非空)varcharAGEint类型;创建ORDERS表,字段为:ID:(非空,主键,)bigintORDER_NUMBER:(非空)varcharPRICEdoubleCUSTOMER_ID :(外键)bigint,设置级连删除;

    答案:create table CUSTOMBERS(

                  ID bigint not null,

                  NAME varchar(15),

                  AGE int,

                  primary key (ID)

                  );

             create table ORDERS(

    ID bigint not null,

    ORDER_NUMBER varchar(15) not nulll,

    PRICE double precision,

    CUSTOMER_ID bigint,

            primary key(ID),

    );

    alter table ORDERS add constraint FK_CUSTOMER foreign key (CUSTOMER_ID) references CUSTOMERS(ID) on delete cascade;

    6.使用左外连接查询,ORDERS CUSTOMERS 表,

    答案:select c.ID, o.CUSTOMER_ID,c.NAME, o.ID ORDER_ID,ORDER_NUMBER from CUSTOMERS c left outer join ORDERS o no c.ID=o.CUSTOMER_ID;

    29 .简述数据库事务的生命周期?(可画流程图)

    答案:

    7.delete from tablea & truncate table tablea的区别

         truncate 语句执行速度快,占资源少,并且只记录页删除的日志;

         delete 对每条记录的删除均需要记录日志

  • 相关阅读:
    腾讯的网站是如何检测到你的 QQ 已经登录?
    怎么改变html中placeholderr的文字颜色
    [分享]2013:Linux的黄金之年-十大杰出成就
    .NET MVC 两种视图引擎(Razor、Aspx)
    android:visibility
    获取目录
    Android 判断字符串是否相等
    Android Sqlite
    android 积累
    Android ListView 使用
  • 原文地址:https://www.cnblogs.com/linzheng/p/1926846.html
Copyright © 2011-2022 走看看