简单的SQL面试题
1. Q. What is a join?
A. Join is a process of retrieve pieces of data from different sets (tables) and returns them to the user or program as one joined collection of data.
2. Q. Can a table have more than one foreign key defined?
A. A table can have any number of foreign keys defined. It can have only
one primary key defined.
3. Q. List all the possible values that can be stored in a BOOLEAN data field.
A. There are only two values that can be stored in a BOOLEAN data field:
-1(true) and 0(false).
4. Q. What is a stored procedure?
A. A procedure is a group of PL/SQL statements that can be called by
a name. Procedures do not return values they perform tasks.
5. Q. What is Normalization?
A. The process of table design is called normalization.
6. Q. Write a SQL SELECT sample of the concatenation operator.
A. SELECT LastName ||',' || FirstName, City from Students;
7. Q. Is the WHERE clause must appear always before the GROUP BY clause in SQL SELECT ?
A. Yes.
The proper order for SQL SELECT
clauses is: SELECT, from, WHERE, GROUP BY, HAVING, ORDER BY.
Only the SELECT and from clause are mandatory.
8. Q. Which operator do you use to return all of the rows
from one query except rows are returned in a second query?
A. You use the MINUS operator to return all rows from one query except
where duplicate rows are found in a second query. The UNION operator
returns all rows from both queries minus duplicates. The UNION ALL operator
returns all rows from both queries including duplicates.
The INTERSECT operator returns only those rows that exist in both queries.
9. Q. Which of the following statements are Data Manipulation Language commands?
A. INSERT
B. UPDAT
相关文档:
SQL语句中的Having子句与where子句之区别
---WHERE句子作用于基本表或试图,从中选择满足条件的元组。HAVING作用于组,从中选择满足条件的组---
在说区别之前,得先介绍GROUP BY这个子句,而在说GROUP子句前,又得先说说“聚合函数”——SQL语言中一种特殊的函数。例如SUM, COUNT, MAX, AVG等。这 ......
SQL语句的优化就是将性能较低的SQL语句转换达成同样目的性能优异的SQL语句
下面我们一起来看看一些可以优化SQL的方法,希望大家多提出意见我们共同学习或者是大家有什么好的优化方法可以提出来共享一下。
第一种优化(使用指定列代替”*”)
使用“*&rdquo ......
CREATE proc [dbo].[proc_DeleteTemplet] (@templeId varchar(15),@errorMessage varchar(50) output)
as
begin
declare @error int
set @error =0
begin tran
delete from tc_templet_Head where fBillNo=@templeId
set @error=@error+@@error
delete from tc_templet_ ......
一直没有找到一种好的方法来引用有返回值的存储过程的方法,使我在添加数据中走了不少的弯路,最近,在查阅了大量的资料之后,终于在微软的一个实例中找到了一种良好的方法。
首先编写好一有返回值的存储过程
create procedure proc_name
@para1 nchar(20), --输入参数
@ ......