You need to modify the STUDENTS table to add a primary key o

题目
单选题
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
解析: 暂无解析
如果没有搜索结果或未解决您的问题,请直接 联系老师 获取答案。
相似问题和答案

第1题:

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

第2题:

Which statement explicitly names a constraint? ()

A. ALTER TABLE student_grades ADD FOREIGN KEY (student_id) REFERENCES students (student_id);

B. ALTER TABLE student_grades ADD CONSTRAINT NAME = student_id_fk FOREIGN KEY (student_id) REFERENCES students (student_id);

C. ALTER TABLE student_grades ADD CONSTRAINT student_id_fk FOREIGN KEY (student_id) REFERENCES students (student_id);

D. ALTER TABLE student grades ADD NAMED CONSTRAINT student_id_fk FOREIGN KEY (student_id) REFERENCES students (student_id);

E. ALTER TABLE student grades ADD NAME student_id_fk FOREIGN KEY (student_id) REFERENCES students (student_id);


参考答案:C

第3题:

You are the database administrator for a retail company. The company owns 270 stores. Every month, each store submits approximately 2,000 sales records, which are loaded into a SQL Server 2000 database at the corporate headquarters.

A Data Transformation Services (DTS) package transforms the sales records, as they are loaded. The package writes the transformed sales records to the Sales table, which has a column for integer primary key values. The IDENTITY property automatically assigns a key value to each transformed sales record.

After loading this month's sales data, you discover that a portion of the data contains errors. You stop loading data, identify the problem records, and delete those records from the database.

You want to reuse the key values that were assigned to the records that you deleted. You want to assign the deleted key values to the next sales records you load. You also want to disrupt users' work as little as possible.

What should you do?

A.Export all records from the Sales table to a temporary table. Truncate the Sales table, and then reload the records from the temporary table.

B.Export all records from the Sales table to a text file. Drop the Sales table, and then reload the records from the text file.

C.Use the DBCC CHECKIDENT statement to reseed the Sales table's IDENTITY property.

D.Set the Sales table's IDENTITY_INSERT property to ON. Add new sales records that have the desired key values.


正确答案:C
解析:Explanation: DBCC CHECKIDENT is used to check the current identity value for the specified table. It can be set to correct the identity value by specifying the RESEED option with DBCC CHECKIDENT.

Note: Example:
Assume that we have a table called test with an identity column with seed (1,1) and 1000 rows and that we delete row 901 to 950. We could then issue the command
DBCC CHECKIDENT (test, reseed, 900)

And load the 50 missing rows. These rows would get the values 901, 902, …,950 in the identity column.
We should then set the identity value to 1000 again:
DBCC CHECKIDENT (test, reseed, 1000)

So that the next new row will have identity 1001.

Incorrect Answers:
A: Exporting the data from the Sales table and then reloading the data will not correct errors contained in the table as these errors will also be exported as they are part of the data already in the table.
B: Exporting the data from the Sales table and then reloading the data will not correct errors contained in the table as these errors will also be exported as they are part of the data already in the table.

D: The SET IDENTITY_INSERT command allows explicit values to be inserted into the identity column of a table. To reuse the old key values from the rows that was deleted would require manual commands and would be awkward. This is not the best solution.

第4题:

为表TEST中ID列添加主键约束的语法是()

  • A、ALTER  TABLE  TEST  CHANGE( ID  INT  PRIMARY  KEY)
  • B、ALTER  TABLE  TEST  ADD( ID  INT  PRIMARY  KEY)
  • C、ALTER  TABLE  TEST  MODIFY( ID  INT  PRIMARY  KEY)
  • D、ALTER  TABLE  TEST  ADD  CONSTRAINT PK  PRIMARY KEY (ID)

正确答案:D

第5题:

某数据库系统中,假设有部门关系 Dept (部门号,部门名,负责人,电话),其中, "部门号"是该关系的主键;员工关系 Emp (员工号,姓名,部门,家庭住址),属性"家 庭住址"包含省、市、街道以及门牌号,该属性是一个( )属性。 创建 Emp 关系的 SQL 语句如下: CREATE TABLE Emp( 员工号 CHAR(4) ( ), 姓名 CHAR(10), 部门 CHAR(4), 家庭住址 CHAR(30), ( ); 为在员工关系 Emp 中增加一个"工资"字段,其数据类型为数字型并保留2 位小数, 可采用的 SQL 语句为( )。

A. 简单 B. 复合 C.多值 D. 派生A. PRIMARY KEY B. NULL C. FOREIGN KEY D. NOT NULLA.PRIMARY KEY NOT NULLB. PRIMARY KEY UNIQUEC. FOREIGN KEY REFERENCES Dept(部门名)D. FOREIGN KEY REFERENCES Dept(部门号)A.ALTER TABLE Emp ADD 工资 CHAR(6,2);B.UPDATA TABLE Emp ADD 工资 NUMERIC(6,2);C.ALTER TABLE Emp ADD 工资 NUMERIC (6,2);D.ALTER TABLE Emp MODIFY 工资 NUMERI C(6,2);


正确答案:B,A,D,C

第6题:

You own a table called EMPLOYEES with this table structure: EMPLOYEE_ID NUMBER Primary KeyFIRST_NAME VARCHAR2(25)LAST_NAME VARCHAR2(25)HIRE_DATE DATEWhat happens when you execute this DELETE statement? DELETE employees; ()

A. You get an error because of a primary key violation.

B. The data and structure of the EMPLOYEES table are deleted.

C. The data in the EMPLOYEES table is deleted but not the structure.

D. You get an error because the statement is not syntactically correct.


参考答案:C

第7题:

Examine the data in the EMPLOYEES table.On the EMPLOYEES table, EMPLOYEE_ID is the primary key. MGR_ID is the ID of managers and refers to the EMPLOYEE_ID. The JOB_ID column is a NOT NULL column.Evaluate this DELETE statement:Why does the DELETE statement fail when you execute it?()

A. There is no row with dept_id 90 in the EMPLOYEES table.

B. You cannot delete the JOB_ID column because it is a NOT NULL column.

C. You cannot specify column names in the DELETE clause of the DELETE statement.

D. You cannot delete the EMPLOYEE_ID column because it is the primary key of the table.


参考答案:C

第8题:

下列说法正确的是()

A.alter table user drop column sex;

B.alter table user add sex varchar(20);

C.alter table user drop sex;

D.alter table user modify id int primary key;


正确答案:D,B,A,C 

第9题:

Click the Exhibit button and examine the data in the EMPLOYEES table.On the EMPLOYEES table, EMPLOYEE_ID is the primary key. MGR_ID is the ID of managers and refers to the EMPLOYEE_ID. The JOB_ID column is a NOT NULL column.Evaluate this DELETE statement:DELETE employee_id, salary, job_idFROM employeesWHERE dept_id = 90;Why does the DELETE statement fail when you execute it?()

A.There is no row with dept_id 90 in the EMPLOYEES table.

B.You cannot delete the JOB_ID column because it is a NOT NULL column.

C.You cannot specify column names in the DELETE clause of the DELETE statement.

D.You cannot delete the EMPLOYEE_ID column because it is the primary key of the table.


参考答案:C

第10题:

You need to meet the business requirements of the packaging department. What should you do?()

  • A、Add the ProductSize data table and the ProductSizeDescriptor column to the Product dimension. Set the order of the ProductSKU attribute to the ProductSizeDescriptor column.
  • B、Add the ProductSize data table as a dimension and then add this dimension to the cube as a Referenced dimension. Set the order of the key attribute of the ProductSize dimension to the ProductSizeDescriptor column.
  • C、Add the ProductSize data table and the ProductSizeDescriptor column to the Product dimension. Create a user-defined hierarchy that has ProductSKU as the top-level attribute and ProductSizeDescriptor as the bottom-level attribute.
  • D、Add the ProductSize data table as a dimension and then add this dimension to the cube as a Referenced dimension. Create a user-defined hierarchy within the ProductSize dimension. Set the ProductSizeDescriptor attribute as the top-level attribute.

正确答案:A

更多相关问题