niusouti.com

如果学生表STUDENT是使用下面的SQL语句创建的:CREATE TABLE STUDENT(SNO C(4) PRIMARY KEY NOT NULL,,;SN C(8),;SEX C(2),;AGE N(2) CHECK(AGE>15 AND AGE<30))下面的SQL语句中可以正确执行的是( )。AA.BB.CC.DD.答案

题目

如果学生表STUDENT是使用下面的SQL语句创建的:

CREATE TABLE STUDENT(SNO C(4) PRIMARY KEY NOT NULL,,;

SN C(8),;

SEX C(2),;

AGE N(2) CHECK(AGE>15 AND AGE<30))

下面的SQL语句中可以正确执行的是( )。

A

A.B

B.C

C.D

D.答案


相似考题
更多“如果学生表STUDENT是使用下面的SQL语句创建的: CREATE TABLE STUDENT(SNO C(4) PRIMARY KEY NOT ”相关问题
  • 第1题:

    根据SQL标准,删除表student中对字段sno的唯一性约束,应该使用下面哪条语句? ()

    A drop sno from table student

    B alter table student drop sno

    C alter table student drop unique(sno)

    D alter table student drop sno unique


    参考答案C

  • 第2题:

    如果学生表STUDENT是使用下面的SQL语句创建的

    CREATE TABLE STUDENT(SNO C(4) PRIMARY KEY NOT NULL,;

    SN C(8),;

    SEX C(2),;

    AGE N(2) CHECK(AGE>15 AND AGE<30))

    下面的SQL语句中可以正确执行的是

    A.INSERT INTO STUDENT(SNO,SEX,AGE)VALUES (“S9”,“男”,17)

    B.INSERT INTO STUDENT(SN,SEX,AGE)VALUES (“李安琦”,“男”,20)

    C.INSERT INTO STUDENT(SEX,AGE)VALUES (“男”,20)

    D.INSERT INTO STUDENT(SNO,SN)VALUES (“S9”,“安琦”,16)


    正确答案:A
    解析:题干中创建表的SQL语句使用了短语PRIMARY KEY,将SNO字段规定为主索引字段,同时使用短语NOT NULL,规定在该字段中不允许出现空值,因此选项B、C都是错误的;而选项D的错误在于,语句中的VALUES后面所描述的插入记录值,与题干中所创建的字段不符;正确选项为A,能够实现插入记录的操作。

  • 第3题:

    如果学生表student是使用下面的SQL谙句创建的: CREATE TABLE student(学号C(6)PRIMARY KEY NOT NULL,姓名C(8),性别C(2),年龄N(2) CHECK(年龄>15 AND年龄<30,)) 则下面的SQL语句中可以正确执行的是( )。

    A. INSERT INTO student(学号,性别,年龄)VALUES(”0542”,”李雷”,”男”,17)

    B. INSERT INTO student(学号,性别,年龄)VALUES(”李雷”,”男”,20)

    C. INSERT INTO student(学号,性别,年龄)VALUES(”女”,25)

    D. INSERT INTO student(学号,性别,年龄)VALUES(”0897”,”安宁”,”女”,30)


    正确答案:A
    由于“学号”是主关键字,不可以为空,因此是必填字段,在用INSERT插入记录时,学号字段的值不可省略,另外在插入记录时,插入数据的个数必须和字段个数相等。

  • 第4题:

    建立一个学生信息表student,要求它由学号sno、姓名sname、性别sex、年龄age4个属性组成,其学号属性唯一,学号、姓名字段不能为空。下列语句正确的是

    A.CREATE TABLE student(sno char(5) NOT NULL sname char(8) NOT NULL sex char(1) age int);

    B.CREATE TABLE student (sno char(5) NOT NULL UNIQUE sname char(8) sex char(1) age int);

    C.CREATE TABLE (sno char(5) NOT NULL UNIQUE sname char(8) NOT NULL sex char(1) age int);

    D.CREATE TABLE student (sno char(5) NOT NULL UNIQUE sname char(8) NOT NULL sex char(1) age int);


    正确答案:D
    解析:A) 选项中,创建sno字段没有唯一性限制;B) 选项中,创建sname字段没有不为空的限制; C) 选项中,创建表没有表明。

  • 第5题:

    若用如下的SQL语句创建一个student表: CREATE TABLE student( N0 C(4)NOT NULL, NAME C(8)NOT NULL, SEX C(2), AGE N(2) ) 可以插入到student表中的是

    A.('1031','曾华',男,23)

    B.('1031','曾华',NULL,NULL)

    C.(NULL,'曾华','男','23')

    D.('1031',NULL,'男',23)


    正确答案:B
    解析:INSERT语句的功能是向表中插入一条记录,但是记录的结构必须符合表的结构。由于表的结构是:NO C(4)NOT NULL,NAME C(8)NOT NULL,SEX C(2),AGE N(2),因此选项A.'1031','曾华',男,23)中的SEX字段不符合要求:选项C.(NULL,'曾华','男', '23')中的AGE字段不符合要求;选项D.('1031', NULL,'男',23)中的NAME字段为NULL,不符合要求,因此只有选项B能够被插入。

  • 第6题:

    如果学生表student是使用下面的SQL语句创建的

    CREATE TABLE student(学号C(4)PRIMARY KEY NOT NULL,;

    姓名C(8),;

    性别C(2),;

    年龄N(2)CHECK(年龄>1 5 AND年龄<30))

    下面的SQL语句中可以正确执行的是( )。

    A)INSERT INTO student(学号,性别,年龄)VALUES(”0542”,”男”,l7)

    B)INSERT INTO student(姓名,性别,年龄VALUES(”李蕾”,”女”,20)

    C)INSERT INTO student(姓名,性别,年龄)VALUES(”男”,25)

    D)INSERT INTO student(学号,姓名)VALUES(”0897”,”安宁”,16)


    正确答案:A
    由于“学号”是主关键字,不可以为空,因此是必填字段,在用INSERT插入记录时,学号字段的值不可省,故选项B)和选项C)不正确,在用INSERT插入记录时,初值的个数必须和字段个数相等。故选项D)不正确。PRIMARYKEYNOTNULL用来定义学号为主关键字,并且不可为NULL值,CHECK(AGE>15 AND AGE<30)语句用来约束字段年龄必须大于15并且小于30。

  • 第7题:

    已知数据表Student存储在SQL Server服务器的School数据库中,用户名为sa,密码为xyz123,创建student数据表的命令为:  CREATE TABLE Student (  SName varchar(20)  Primary Key Not NULL,  SPwd Varchar(15) Not NULL  )  试根据下面的代码使用命令对象完成在student数据表中插入一条记录。  <%  tname = Request.Form("txtName")  ’接收到的用户名  tpwd = Request.Form("txtPwd")   ’接收到的密码  %>


    正确答案: <%
    Set conn = Server.CreateObject("ADODB.Connection")
    Conn.Open "Driver={SQL Server};Server=(local);UID=sa;PWD=xyz123;database=School"
    Set comm = Server.CreateObject("ADODB.Command")
    Comm.ActiveConnection=conn
    Comm.CommandText = "Insert into student values(’"&tname&"’,’"&tpwd&"’)"
    Comm.Execute
    Conn.Close
    Set conn = Nothing
    %>

  • 第8题:

    You need to modify the STUDENTS table to add a primary key on the STUDENT_ID column. The table is currently empty.Which statement accomplishes this task?()

    • A、ALTER TABLE students ADD PRIMARY KEY student_id;
    • B、ALTER TABLE students ADD CONSTRAINT PRIMARY KEY (student _ id);
    • C、ALTER TABLE students ADD CONSTRAINT stud _ id _pk PRIMARY KEY (student _ id);
    • D、ALTER TABLE students MODIFY CONSTRAINT stud _ id _pk PRIMARY KEY (student _ id);

    正确答案:C

  • 第9题:

    You need to modify the STUDENTS table to add a primary key on the STUDENT_ID column. The table is currently empty.Which statement accomplishes this task?()

    • A、ALTER TABLE students   ADD PRIMARY KEY student_id;
    • B、ALTER TABLE students   ADD CONSTRAINT PRIMARY KEY (student_id);
    • C、ALTER TABLE students   ADD CONSTRAINT stud_id_pk PRIMARY KEY student_id;
    • D、ALTER TABLE students   ADD CONSTRAINT stud_id_pk PRIMARY KEY (student_id);
    • E、ALTER TABLE students   MODIFY CONSTRAINT stud_id_pk PRIMARY KEY (student_id);

    正确答案:D

  • 第10题:

    问答题
    已知数据表Student存储在SQL Server服务器的School数据库中,用户名为sa,密码为xyz123,创建student数据表的命令为:  CREATE TABLE Student (  SName varchar(20)  Primary Key Not NULL,  SPwd Varchar(15) Not NULL  )  试根据下面的代码使用命令对象完成在student数据表中插入一条记录。

    正确答案: <%
    Set conn = Server.CreateObject("ADODB.Connection")
    Conn.Open "Driver={SQL Server};Server=(local);UID=sa;PWD=xyz123;database=School"
    Set comm = Server.CreateObject("ADODB.Command")
    Comm.ActiveConnection=conn
    Comm.CommandText = "Insert into student values(’"&tname&"’,’"&tpwd&"’)"
    Comm.Execute
    Conn.Close
    Set conn = Nothing
    %>
    解析: 暂无解析

  • 第11题:

    单选题
    You need to design a student registration database that contains several tables storing academic information. The STUDENTS table stores information about a student. The STUDENT_GRADES table stores information about the student's grades. Both of the tables have a column named STUDENT_ID. The STUDENT_ID column in the STUDENTS table is a primary key. You need to create a foreign key on the STUDENT_ID column of the STUDENT_GRADES table that points to the STUDENT_ID column of the STUDENTS table. Which statement creates the foreign key?()
    A

    CREATE TABLE student_grades (student_id NUMBER(12),semester_end DATE, gpa NUMBER(4,3), CONSTRAINT student_id_fk REFERENCES (student_id) FOREIGN KEY student (student_id));

    B

    CREATE TABLE student_grades(student_id NUMBER(12),semester_end DATE, gpa NUMBER(4,3), student_id_fk FOREIGN KEY (student_id) REFERENCES students (student_id));

    C

    CREATE TABLE student_grades(student_id NUMBER(12),semester_end DATE, gpa NUMBER(4,3), CONSTRAINT FOREIGN KEY (student_id) REFERENCES student (student_id));

    D

    CREATE TABLE student_grades(student_id NUMBER(12),semester_end DATE, gpa NUMBER(4,3), CONSTRAINT student_id_fk FOREIGN KEY (student_id) REFERENCES students (student_id));


    正确答案: D
    解析: 暂无解析

  • 第12题:

    单选题
    You need to modify the STUDENTS table to add a primary key on the STUDENT_ID column. The table is currently empty.Which statement accomplishes this task?()
    A

    ALTER TABLE students ADD PRIMARY KEY student_id;

    B

    ALTER TABLE students ADD CONSTRAINT PRIMARY KEY (student _ id);

    C

    ALTER TABLE students ADD CONSTRAINT stud _ id _pk PRIMARY KEY (student _ id);

    D

    ALTER TABLE students MODIFY CONSTRAINT stud _ id _pk PRIMARY KEY (student _ id);


    正确答案: D
    解析: 暂无解析

  • 第13题:

    根据SQL标准,下面哪句语句能够找出年龄最小的同学?其中age为学生表student中的年龄字段,sno为学生的学号。()

    A select max(age) from student

    B select sno from student where age = max(age)

    C select sno from student having age = max(age)

    D select sno from student a where a.age<= (select min(b.age) from student b)


    参考答案D

  • 第14题:

    如果学生表STUDENT是使用下面的SQL语句创建的: CREATE TABLE STUDENT(SNO C(4)PRIMARY KEY NOT NULL. SN C(8), SEX C(2), AGE N(2)CHECK(AGE>15 AND AGE<25)) 下面的SQL语句中可以正确执行的是( )。

    A. INSERT INTO STUDENT(SN,SEX,AGE)VALUES(”王磊”,”男”,20)

    B. INSERT INTO STUDENT(SN0,SEX,AGE)VALUES(”S9”,”男”,17)

    C. INSERT INTO STUDENT(SEX,AGE)VALUES(”男”,20)

    D. INSERT INTO STUDENT(SN0,SN,AGE)VALUES(”S9”,”王磊”,14)


    正确答案:B
    由于SN0项不可以为空,是必填字段,在用INSERT插入记录时,SN0字段的值不可省,故A、c不正确,在用INSERT插入记录时,D项中的年龄不符合约束条件,故D不正确。
    INSERT语句的格式为:
    INSERT INTO dbf__name[(fnamel[,fname2,...])]VALUES(eExpressionl[,eExpression2,...j)
    PRIMARY KEY NOT NULL用来定义SN0为主关键字,并且不可为NULL值;
    CHECK(ACE>15 AND AGE<25)语句用来约束字段 AGE必须大于l5并且小于25。

  • 第15题:

    如果学生表STUDENT是使用下面的SQL语句创建的 CREATE TABLE STUDENT(SNOC(4)PR1MARY KEY NOTNULL; SNC(8),; SEXC(2),; AGEN(2)CHECK(AGE>15AND AGE<30) 下面的SQI语句中可以正确执行的是 ______。

    A.INSERT INTO STUDENT(SNO,SEX,AGE)valueS("S9","男",17)

    B.INSERT INTO STUDENT(SNO,SEX,AGE)valueS(“李安琦”,“男”,20)

    C.INSERT INTO STUDENT(SEX,AGE)valueS(“男”,20)

    D.INSERT INTO STUDENT(SNO,SN)valueS("S9",“安琦”,16)


    正确答案:A
    解析:本题中SNO字段值在定义时为主关键字,所以不能为空。当插入一条新的记录时;必须保证此字段有数据,且插入的数据如果为字符型数据,要加双引号。

  • 第16题:

    一个学生信息表student,要求它由学号sno,姓名sname,性别sex,年龄age,4个属性组成。现在对这个现有的表增加一个入学时间cometime字段为日期型,下列语句正确的是

    A.ALTER TABLE student ADD cometime DATE NOT NULL;

    B.ALTER TABLE student ADD cometime DATE;

    C.ALTER TABLE student DROP cometime DATE NOT NULL:

    D.ALTER TABLE student MODIFY cometime DATE;


    正确答案:B
    解析:新增加的列一律允许为空值。故A)错。DROP用于删除指定的完整性约束,故C)错。MODIFY用于修改原有的列定义,故D)错。

  • 第17题:

    建立一个学生信息表student,要求它由学号sno,姓名sname,性别sex,年龄age,4个属性组成,其学号属性惟一,学号、姓名字段不能为空。下列语句正确的是

    A.CREATE TABLE student (sno char(5)NOT NULL sname char(8)NOT NULL sex char age int);

    B.CREATE TABLE student (sno char(5)NOT NULL UNIQUE sname char(8) sex char age int);

    C.CREATE TABLE (sno char(5)NOT NULL UNIQUE sname char(8)NOT NULL sex char age int);

    D.CREATE TABLE student (sno char(5)NOT NULL UNIQUE sname char(8)NOT NULL sex char age int);


    正确答案:D
    解析:本题主要考查了SQL语言中,创建基本表的方法。 A)选项中,创建sno字段没有惟一性限制;B)选项中,创建sname字段没有不为空的限制;C)选项中,创建表没有表明。

  • 第18题:

    You need to design a student registration database that contains several tables storing academic information. The STUDENTS table stores information about a student. The STUDENT_GRADES table stores information about the student's grades. Both of the tables have a column named STUDENT_ID. The STUDENT_ID column in the STUDENTS table is a primary key. You need to create a foreign key on the STUDENT_ID column of the STUDENT_GRADES table that points to the STUDENT_ID column of the STUDENTS table. Which statement creates the foreign key?()

    • A、CREATE TABLE student_grades (student_id NUMBER(12),semester_end DATE, gpa NUMBER(4,3), CONSTRAINT student_id_fk REFERENCES (student_id) FOREIGN KEY student (student_id));
    • B、CREATE TABLE student_grades(student_id NUMBER(12),semester_end DATE, gpa NUMBER(4,3), student_id_fk FOREIGN KEY (student_id) REFERENCES students (student_id));
    • C、CREATE TABLE student_grades(student_id NUMBER(12),semester_end DATE, gpa NUMBER(4,3), CONSTRAINT FOREIGN KEY (student_id) REFERENCES student (student_id));
    • D、CREATE TABLE student_grades(student_id NUMBER(12),semester_end DATE, gpa NUMBER(4,3), CONSTRAINT student_id_fk FOREIGN KEY (student_id) REFERENCES students (student_id));

    正确答案:D

  • 第19题:

    在SQL Sever中,创建数据库student,使用的语句是()。

    • A、CREATE TABLE student
    • B、CREATE VIEW student
    • C、CREATE PROC student
    • D、CREATE DATABASE student

    正确答案:D

  • 第20题:

    You need to modify the STUDENTS table to add a primary key on the STUDENT_ID column. The table is currently empty. Which statement accomplishes this task?()

    • A、ALTER TABLE students ADD PRIMARY KEY _ id;
    • B、ALTER TABLE students ADD CONSTRAINT PRIMARY KEY (student_id);
    • C、ALTER TABLE students ADD CONSTRAINT stud_id_pk PRIMARY KEY student_id;
    • D、ALTER TABLE students ADD CONSTRAINT stud_id_pk PRIMARY KEY (student_id);
    • E、ALTER TABLE students MODIFY CONSTRAINT stud_id_pk PRIMARY KEY (student_id);

    正确答案:D

  • 第21题:

    单选题
    在SQL Sever中,创建数据库student,使用的语句是()。
    A

    CREATE TABLE student

    B

    CREATE VIEW student

    C

    CREATE PROC student

    D

    CREATE DATABASE student


    正确答案: C
    解析: 暂无解析

  • 第22题:

    单选题
    You need to modify the STUDENTS table to add a primary key on the STUDENT_ID column. The table is currently empty. Which statement accomplishes this task?()
    A

    ALTER TABLE students ADD PRIMARY KEY _ id;

    B

    ALTER TABLE students ADD CONSTRAINT PRIMARY KEY (student_id);

    C

    ALTER TABLE students ADD CONSTRAINT stud_id_pk PRIMARY KEY student_id;

    D

    ALTER TABLE students ADD CONSTRAINT stud_id_pk PRIMARY KEY (student_id);

    E

    ALTER TABLE students MODIFY CONSTRAINT stud_id_pk PRIMARY KEY (student_id);


    正确答案: D
    解析: 暂无解析

  • 第23题:

    单选题
    You need to modify the STUDENTS table to add a primary key on the STUDENT_ID column. The table is currently empty. Which statement accomplishes this task?()
    A

    ALTER TABLE students ADD PRIMARY KEY student_id;

    B

    ALTER TABLE students ADD CONSTRAINT PRIMARY KEY (student_id);

    C

    ALTER TABLE students ADD CONSTRAINT stud_id_pk PRIMARY KEY student_id;

    D

    ALTER TABLE students ADD CONSTRAINT stud_id_pk PRIMARY KEY (student_id);

    E

    ALTER TABLE students MODIFY CONSTRAINT stud_id_pk PRIMARY KEY (student_id);


    正确答案: A
    解析: 暂无解析