题目一、
有两个表:

TableX有三个字段Code、 Name、 Age、 其中Code为主键;
TableY有三个字段Code、 Class、Score, 其中Code + Class 为主键。两表记录如下:

Code Name Age Code Class Score
97001 张三 22 97001 数学 80
97002 赵四 21 97002 计算机 59
97003 张飞 20 97003 计算机 60
97004 李五 22 97004 数学 55
1、请写出SQL,找出所有姓张的学生,并按年龄从小到大排列;
2、请写出SQL,取出计算机科考成绩不及格的学生;
3、通过等值联接,取出Name、Class、Score,请写出SQL即输出结果
4、通过外联接,取出每个学生的Name、Class、Score、请写SQL输出结果
5、请写SQL,在TableX 表中增加一条学生记录(学号:97005 姓名:赵六 年龄:20);
6、李五的年龄记录错了,应该是21,请写SQL,根据主键进行更新;
7、请写SQL,删除TableX中没有考试成绩的学生记录,请使用not in条件;
题目二、
有两个表定义如下:
create tableindividual (
firstname   varchar2(20) not null
lastname    vatchar2(20) not null
birthdate   date
gender      varchar2(1) 
initial     number(2)
farorite    varchar2(6)
type        varchar2(8)
);在此表中建唯一索引 firstname + lastnamecreate table chile_detail(
firstname   varchar2(20)
lastname    varchar2(20)
cname       varchar2(8)
coment      varchar2(2)
type        varchar2(8)
);
1、写一个简单的SQL语句实现:删除表individual中一条出生日期(brithdate)为 1990年10月2日 出生的人的记录2、写一修改语句实现: 将表child_detail 中的type 为 “kkd” 的记录的Cname 值为“declear”,coment的值为“02”

解决方案 »

  1.   

    7题是这个意思吗?
    delete from x 
    where code not in(select code from y)
      

  2.   

    delete from tablex where code not in (select code from tabley);
      

  3.   

    感觉今天好像CSDN系统有问题。
      

  4.   

    TableX有三个字段Code、 Name、 Age、 其中Code为主键; 
    TableY有三个字段Code、 Class、Score, 其中Code + Class 为主键。两表记录如下: Code Name Age Code Class Score 
    97001 张三 22 97001 数学 80 
    97002 赵四 21 97002 计算机 59 
    97003 张飞 20 97003 计算机 60 
    97004 李五 22 97004 数学 55 
    1、请写出SQL,找出所有姓张的学生,并按年龄从小到大排列; 
     select * from TableX where name like '张%' order by age2、请写出SQL,取出计算机科考成绩不及格的学生; 
     select * from tableX where code in (select code from tableY WEHRE class='计算机' and score<60)3、通过等值联接,取出Name、Class、Score,请写出SQL即输出结果 
     select a.name,b.class,b.score from tableX a,tableY b where a.code=b.code  4、通过外联接,取出每个学生的Name、Class、Score、请写SQL输出结果 
     select a.name,b.class,b.score from tableX full join tableY on a.code=b.code5、请写SQL,在TableX 表中增加一条学生记录(学号:97005 姓名:赵六 年龄:20);
    insert into tablex values('97005','赵六',20) 
    6、李五的年龄记录错了,应该是21,请写SQL,根据主键进行更新; 
    update tablex set age=21 where code='97004'7、请写SQL,删除TableX中没有考试成绩的学生记录,请使用not in条件; 
    delete tablex where code not in (select code from tabley)
      

  5.   

    看了第七题时,当时的写法是:
    DELETE TABLEX WHERE CODE IN (
    SELECT CODE FROM TABLEX WHERE CODE NOT IN(SELECT Y.CODE FROM TABLEY))
    但看了其它人的写法,感觉自己写的不简洁,学习一下.
      

  6.   

    题目一、 
    有两个表: TableX有三个字段Code、 Name、 Age、 其中Code为主键; 
    TableY有三个字段Code、 Class、Score, 其中Code + Class 为主键。两表记录如下: Code Name Age Code Class Score 
    97001 张三 22 97001 数学 80 
    97002 赵四 21 97002 计算机 59 
    97003 张飞 20 97003 计算机 60 
    97004 李五 22 97004 数学 55 
    1、请写出SQL,找出所有姓张的学生,并按年龄从小到大排列; 
    select code,name,age from tableX where name like '张%' ORDER BY AGE
    2、请写出SQL,取出计算机科考成绩不及格的学生; 
    SELECT Y.NAME,X.CLASS,X.SCORE FROM TABLEY Y,TABLEX X WHERE CLASS='计算机' AND SCORE <60 AND Y.CODE=X.CODE 3、通过等值联接,取出Name、Class、Score,请写出SQL即输出结果 SELECT Y.NAME,X.CLASS,X.SCORE FROM TABLEY Y,TABLEX X WHERE Y.CODE=X.CODE 
    4、通过外联接,取出每个学生的Name、Class、Score、请写SQL输出结果 
    5、请写SQL,在TableX 表中增加一条学生记录(学号:97005 姓名:赵六 年龄:20); 
    INSERT INTO TABLEX(CODE,NAME,AGE)VALUES('97005','赵六','20')6、李五的年龄记录错了,应该是21,请写SQL,根据主键进行更新; 
    UPDATE TABLEX SET AGE=21 WHERE CODE='97004'7、请写SQL,删除TableX中没有考试成绩的学生记录,请使用not in条件; 
    DELETE FROM TABLEX WHERE CODE NOT IN(SELECT DISTINCT CODE FROM TABLEY)题目二、 
    有两个表定义如下: 
    create table individual ( 
    firstname  varchar2(20) not null 
    lastname    vatchar2(20) not null 
    birthdate  date 
    gender      varchar2(1) 
    initial    number(2) 
    farorite    varchar2(6) 
    type        varchar2(8) 
    ); 在此表中建唯一索引 firstname + lastname 
    alter table individual
      add constraint PK_individual unique (firstname , lastname )
    create table chile_detail( 
    firstname  varchar2(20) 
    lastname    varchar2(20) 
    cname      varchar2(8) 
    coment      varchar2(2) 
    type        varchar2(8) 
    ); 
    1、写一个简单的SQL语句实现:删除表individual中一条出生日期(brithdate)为 1990年10月2日 出生的人的记录 
    delete from individual where to_char(birthdate,'yyyy-mm-dd')='1990-10-02'2、写一修改语句实现: 将表child_detail 中的type 为 “kkd” 的记录的Cname 值为“declear”,coment的值为“02” 
    update child_detail set cname='declear',coment='02' where type='kkd'
      

  7.   

    终于做完了,难道这个岗位很基础?会点查询、插入、修改、删除就行了吗?
    1、请写出SQL,找出所有姓张的学生,并按年龄从小到大排列;
    Select a.code,a.name,a.age,b.class,b.score From TableX a,TableY b Where a.name Like '张%' And a.CODE=b.CODE Order By a.Age desc2、请写出SQL,取出计算机科考成绩不及格的学生; 
    Select a.code,a.name,a.age,b.class,b.score From TableX a,TableY b Where b.score<60 And a.CODE=b.CODE
    3、通过等值联接,取出Name、Class、Score,请写出SQL即输出结果 
    Select a.name,b.class,b.score From TableX a,TableY  b Where  a.CODE=b.CODE4、通过外联接,取出每个学生的Name、Class、Score、请写SQL输出结果 
    Select a.name,b.class,b.score From TableX a,TableY b Where  a.CODE(+)=b.CODE
    5、请写SQL,在TableX 表中增加一条学生记录(学号:97005 姓名:赵六 年龄:20);
    Insert Into TableX (code,name,age) Values ('97005','赵六',20) 
    6、李五的年龄记录错了,应该是21,请写SQL,根据主键进行更新; 
    Update TableX Set Age=21 Where Code=97004
    7、请写SQL,删除TableX中没有考试成绩的学生记录,请使用not in条件; 
    Delete From TableX Where Code Not IN (Select Code From TableY)
    1、写一个简单的SQL语句实现:删除表individual中一条出生日期(brithdate)为 1990年10月2日 出生的人的记录 Delete From Individual Where BrithDate=To_Date(‘1990-10-02’,’yyyy-mm-dd’);
    2、写一修改语句实现: 将表child_detail 中的type 为 “kkd” 的记录的Cname 值为“declear”,coment的值为“02”
    Update chile_detail Set cname=’declear’,coment=02 Where type=’kkd’;
      

  8.   

    1、请写出SQL,找出所有姓张的学生,并按年龄从小到大排列; 
    SELECT * FROM TableX WHERE Name LIKE '张%' ORDER BY Age;
    2、请写出SQL,取出计算机科考成绩不及格的学生; 
    SELECT * FROM TableX x, TableY y WHERE x.Code = y.Code AND Class = '计算机' AND Score < 60;
    3、通过等值联接,取出Name、Class、Score,请写出SQL即输出结果 
    SELECT x.Name, y.Class, y.Score FROM TableX x, TableY y WHERE x.Code = y.Code
    4、通过外联接,取出每个学生的Name、Class、Score、请写SQL输出结果 
    Left Out:SELECT x.Name, y.Class, y.Score FROM TableX x, TableY y WHERE x.Code = y.Code(+)
    Right Out: SELECT x.Name, y.Class, y.Score FROM TableX x, TableY y WHERE x.Code(+) = y.Code
    Full Out:Left join union all right join
    5、请写SQL,在TableX 表中增加一条学生记录(学号:97005 姓名:赵六 年龄:20); 
    INSERT INTO TableX(Code, Name, Age) VALUES('97005','赵六',20);
    COMMIT;6、李五的年龄记录错了,应该是21,请写SQL,根据主键进行更新; 
    UPDATE TableX SET Age = 21 WHERE Code in (SELECT Code FROM TableX WHERE Name = '李五')
    7、请写SQL,删除TableX中没有考试成绩的学生记录,请使用not in条件; 
    DELETE FROM TableX WHERE Code Not in (SELECT Code FROM TableY WHERE NVL(Score,0) = 0)
    在此表中建唯一索引 firstname + lastname 
    CREATE UNIQUE INDEX NAME_UNINDEX ON individual(firstname,lastname)
    1、写一个简单的SQL语句实现:删除表individual中一条出生日期(brithdate)为 1990年10月2日 出生的人的记录 
    DELETE FROM individual WHERE TO_CHAR(birthdate,'YYYY-MM-DD') = '1990-10-02';
    COMMIT;2、写一修改语句实现: 将表child_detail 中的type 为 “kkd” 的记录的Cname 值为“declear”,coment的值为“02” 
    UPDATE chile_detail SET Cname = 'declear', coment = '02'
    WHERE type = 'kkd';
    COMMIT;
      

  9.   

    所以說,現在的面試就是這樣,認爲你這麽簡單的東西都不會,其他的就不用説了。加強自身的基礎知識吧。努力學習Oracle……
      

  10.   

    1
    select * from tableX where name like '张%' order by age asc
    2
    select tableX.* from tableX left join tableY on tableY.code=tableX.code where tableY.class='计算机' and tableY.score<60select * from tableX where code in (select code from tableY where class='计算机' and score<60)3
    select tableX.name,tableY.class,tableY.score from tableX,tableY where tableX.code=tableY.code4
    select tableX.* from tableX left join tableY on tableY.code=tableX.code 5
    请写SQL,在TableX 表中增加一条学生记录(学号:97005 姓名:赵六 年龄:20);
    insert into TableX(code,name,age) values(97005,'赵六',20)6
    李五的年龄记录错了,应该是21,请写SQL,根据主键进行更新
    update tableX set age=21 where name='李五'7
    delete tableX where code not in (select code from tableY)
      

  11.   

    写一个简单的SQL语句实现:删除表individual中一条出生日期(brithdate)为 1990年10月2日 出生的人的记录
    --前提是一条记录然而出生日期相同的人大有人在不止一个
    delete individual where exists (select count(*)  as num from individual where brithdate=to_date(1990-10-02,'yyyymmdd')
    having num=1)
      

  12.   

    如果是多条记录写的跟复杂点在不建表的提前下!估计还要用游标!
    或者declare pl_sql
      

  13.   

    大专生怎么这么难找工作即使有两年的DBA经验!
      

  14.   

    两年dba经验???????????????????
      

  15.   

    delete from tablex x where x.code not in(select y.code from tabley 
    y where y.score!=null)
      

  16.   

    1
    select * from tableX where name like '张%' order by age asc
    2
    select tableX.* from tableX left join tableY on tableY.code=tableX.code where tableY.class='计算机' and tableY.score<60select * from tableX where code in (select code from tableY where class='计算机' and score<60)3
    select tableX.name,tableY.class,tableY.score from tableX,tableY where tableX.code=tableY.code4
    select tableX.* from tableX left join tableY on tableY.code=tableX.code 5
    请写SQL,在TableX 表中增加一条学生记录(学号:97005 姓名:赵六 年龄:20);
    insert into TableX(code,name,age) values(97005,'赵六',20)6
    李五的年龄记录错了,应该是21,请写SQL,根据主键进行更新
    update tableX set age=21 where name='李五'7
    delete tableX where code not in (select code from tableY)
      

  17.   


    1.
    select * from TabelX x,TableY y where x.code = y.code
    and x.name like '张%' order by x.age asc
    2.
    select * from TabelX x,TableY y where
    x.code=y.code and  y.class='计算机'
    and y.score<60
    3.
    select x.name,y.class,y.score from TabelX x,TableY y
    where x.code=y.code
    4.
    select x.name,y.class,y.score from TabelX x,TableY y
    where x.code=y.code(+)select x.name,y.class,y.score from TabelX x left join TableY y
    on x.code=y.code 7.
    select * from TabelX x where x.code not in (select y.code from TableY y)
      

  18.   

     here and later back
      

  19.   

    其实都是基础性的题目,一道挂了,也难怪啊!7:delete from tableX where code in (select code from tableY where score is null) or code not in (select distinct code from tableY)
      

  20.   

    1
    SELECT * FROM X WHERE Name LIKE '%张' ORDER BY Age
    2
    SELECT * FROM Y WHERE Class ='计算机' AND Score <60
    3
    SELECT X.Name Y.Class Y.Score FORM X ,Y WHERE X.Code =Y.Code 
    4
    SELECT X.Name Y.Class Y.Score FORM X FULL JION Y WHERE X.Code =Y.Code 
    5
    INSERT INTO X (Code,Name,Age) VALUES('97005','赵六','20')

    UPDATE X SET AGE='21' WHERE NAME='李五'
    7
    DELETE FROM X WHERE Code  not in(SELECT CODE FROM X ,Y 
    WHERE Y.Score <>'' OR Y.Score IS NULL)
      

  21.   

    7.delete from tablex where code not in
    (select code  from tabley where score is not null) ;
      

  22.   

    第6题要求主键更新,应该加条语句
    SELECT CODE FROM X WHERE NAME='李五';
      

  23.   

    题目一、 
    有两个表: TableX有三个字段Code、 Name、 Age、 其中Code为主键; 
    TableY有三个字段Code、 Class、Score, 其中Code + Class 为主键。两表记录如下:Code Name Age Code Class Score 
    97001 张三 22 97001 数学 80 
    97002 赵四 21 97002 计算机 59 
    97003 张飞 20 97003 计算机 60 
    97004 李五 22 97004 数学 55 
    1、请写出SQL,找出所有姓张的学生,并按年龄从小到大排列; 
    select *
    from tablex
    where name like '张%' 
    order by age;
    2、请写出SQL,取出计算机科考成绩不及格的学生; 
    select *
    from tabley
    where score < 60
    and class = '计算机'
    3、通过等值联接,取出Name、Class、Score,请写出SQL即输出结果
    select x.name,y.class,y.score
    from tablex x,tabley y
    where x.code = y.code;
    4、通过外联接,取出每个学生的Name、Class、Score、请写SQL输出结果
    select x.name,y.class,y.score
    from tablex x,tabley y
    where x.code = y.code(+);
    5、请写SQL,在TableX 表中增加一条学生记录(学号:97005 姓名:赵六 年龄:20);
    insert into tablex values(97005,'赵六',20);
    6、李五的年龄记录错了,应该是21,请写SQL,根据主键进行更新;
    update tablex 
    set age = 21 
    where code = 97004;
    7、请写SQL,删除TableX中没有考试成绩的学生记录,请使用not in条件;
    delete from tablex where code not in (select code from tabley);
    题目二、
    有两个表定义如下:
    create tableindividual (
    firstname varchar2(20) not null
    lastname vatchar2(20) not null
    birthdate date
    gender varchar2(1)  
    initial number(2)
    farorite varchar2(6)
    type varchar2(8)
    );在此表中建唯一索引 firstname + lastname
    create unqiue index idx_name on tableindividual(firstname,lastname);create table chile_detail(
    firstname varchar2(20)
    lastname varchar2(20)
    cname varchar2(8)
    coment varchar2(2)
    type varchar2(8)
    );
    1、写一个简单的SQL语句实现:删除表individual中一条出生日期(brithdate)为 1990年10月2日 出生的人的记录
    delete from tableindividual where to_char(birthdate,'yyyymmdd') = '19901002';2、写一修改语句实现: 将表child_detail 中的type 为 “kkd” 的记录的Cname 值为“declear”,coment的值为“02”
    update chile_detail set cname = 'declear',coment = '02' where type = 'kkd';
      

  24.   

    题目一、 
    有两个表: TableX有三个字段Code、 Name、 Age、 其中Code为主键; 
    TableY有三个字段Code、 Class、Score, 其中Code + Class 为主键。两表记录如下:Code Name Age Code Class Score 
    97001 张三 22 97001 数学 80 
    97002 赵四 21 97002 计算机 59 
    97003 张飞 20 97003 计算机 60 
    97004 李五 22 97004 数学 55 
    1、请写出SQL,找出所有姓张的学生,并按年龄从小到大排列; 
    2、请写出SQL,取出计算机科考成绩不及格的学生; 
    3、通过等值联接,取出Name、Class、Score,请写出SQL即输出结果
    4、通过外联接,取出每个学生的Name、Class、Score、请写SQL输出结果
    5、请写SQL,在TableX 表中增加一条学生记录(学号:97005 姓名:赵六 年龄:20);
    6、李五的年龄记录错了,应该是21,请写SQL,根据主键进行更新;
    7、请写SQL,删除TableX中没有考试成绩的学生记录,请使用not in条件;
    题目二、
    有两个表定义如下:
    create tableindividual (
    firstname varchar2(20) not null
    lastname vatchar2(20) not null
    birthdate date
    gender varchar2(1)  
    initial number(2)
    farorite varchar2(6)
    type varchar2(8)
    );在此表中建唯一索引 firstname + lastnamecreate table chile_detail(
    firstname varchar2(20)
    lastname varchar2(20)
    cname varchar2(8)
    coment varchar2(2)
    type varchar2(8)
    );
    1、写一个简单的SQL语句实现:删除表individual中一条出生日期(brithdate)为 1990年10月2日 出生的人的记录2、写一修改语句实现: 将表child_detail 中的type 为 “kkd” 的记录的Cname 值为“declear”,coment的值为“02”看似简单的题目,其实暗藏“陷阱”
    比如 
    7、请写SQL,删除TableX中没有考试成绩的学生记录,请使用not in条件;
    需求不明确,所以结果也有多个
    (一)没有考试成绩的,在TableY中没有记录
    delete from TableX code not in (select code from TableY)
    (二)没有考试成绩的,在TableY有记录,只是没有分数(如:缺考的等),个人感觉这个更符合要求
    delete from TableX code not in (select code from TableY where score is not null) 
     (三) 现实中,可能还有这种比较复杂的情况,假如,三门功课,只有一门有成绩,删不删除了?
     
     1、写一个简单的SQL语句实现:删除表individual中一条出生日期(brithdate)为 1990年10月2日 出生的人的记录
    --前提是一条记录然而出生日期相同的人大有人在不止一个
    delete from individual where brithdate=to_date(1990-10-02,'yyyymmdd') and rownum=1
    笔试时,一定要搞清楚题意在下笔呀!
      

  25.   

    so easy的题目,第7题LZ写的那么复杂?? 不给面试不就算了,无所谓的,出这么简单题目面试估计也没有多少钱给你
      

  26.   

    这公司肯定没开发support DBA,居然最后一题指明用not in 来写。
      

  27.   


    顶,delete from tablex x where x.code not in(select y.code from tabley
    y where y.score is not null;
      

  28.   


    1>select Name from TableX where Name like 'ÕÅ%' order by Age ASC2>select X.Name from TableX X left join TableY Y on X.code=Y.code where Y.class='计算机' and score<60
      select Name from TableX where Code in(select code from TableY where Class='计算机'and Score<60)
      
    3>select X.Name,Y.Class,Y.Score from TableX X join TableY Y on X.code=Y.code
      select X.Name,Y.Class,Y.Score from TableX X, TableY Y where X.code=Y.code
      
    4> select X.Name,Y.Class,Y.Score from TableX X full join TableY Y on X.code=Y.code   5>insert into TableX values(97005,'李五',20)6>update TableX set Age=21 where Code=(select code from TableX where Name='李五')7>delete from TableX where Code not in (select Code form TableY)