jdbc知识问答
2015-07-10 22:05
281 查看
1 JDBC连接数据库6步
Load the JDBC Driver
Establish the Database Connection
Create a Statement Object
Execute a Query
Process the Results
Close the Connection
2 事务的4大特性
答:原子性A,一致性C,隔离性I,永久性D
3.select count(*) from student 和select count(id) 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:(非空,主键)bigint,NAME:(非空)varchar,AGE:int类型;创建ORDERS表,字段为:ID:(非空,主键,)bigint,ORDER_NUMBER:(非空)varchar,PRICE:double,CUSTOMER_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 对每条记录的删除均需要记录日志
Load the JDBC Driver
Establish the Database Connection
Create a Statement Object
Execute a Query
Process the Results
Close the Connection
2 事务的4大特性
答:原子性A,一致性C,隔离性I,永久性D
3.select count(*) from student 和select count(id) 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:(非空,主键)bigint,NAME:(非空)varchar,AGE:int类型;创建ORDERS表,字段为:ID:(非空,主键,)bigint,ORDER_NUMBER:(非空)varchar,PRICE:double,CUSTOMER_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 对每条记录的删除均需要记录日志
相关文章推荐
- Eclipse无法导入现有项目的解决方法
- jdbc知识问答 分类: 面试 2015-07-10 22:05 5人阅读 评论(0) 收藏
- vs中常用的快捷键
- 开篇
- 内存模型(memory models)和命名空间(namespace)
- java的引用和C++的指针有什么区别
- 学习笔记 02计算器界面
- 数据库优化-基准测试(三)
- 统计数组中不同元素出现的次数(时间复杂度O(n),空间复杂度o(1))
- Struts知识问答
- Hadoop入门进阶课程4--HDFS原理及操作
- MFC应用程序开机自启动
- 程序设计语言----实践之路 读书笔记(1)
- reachability的基本理解
- Fail Fast Vs Fail Safe Iterator In Java : Java Developer Interview Questions
- 基于ZooKeeper的分布式Session实现
- asp.net 发送邮件代码 System.Net.Mail
- JavaWeb学习笔记——开发动态WEB资源(七)
- Java学习笔记01 布局
- RAID 磁盘阵列的应用