uNIT3(LABORAOTRY) Flashcards

1
Q

You can alter an existing table by adding one or more columns. In the following example, you add the column named p_salecode to the tbl_product table.

A

alter table tbl_product
add p_salecode char(1)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Altering/Changing a Column
If we want to change the size of column pt_name in table tbl_part from varchar(500) to varchar(250)

A

// SQL Server
alter table tbl_part
alter column pt_name varchar(250);

// MySQL
alter table tbl_part
modify column pt_name varchar(250);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Dropping a Column
Suppose that you want to delete the V_ORDER attribute from the VENDOR table.

A

(SQL Server and MySQL)
alter table tbl_vendor
drop column v_order

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Adding Primary Key and Foreign Keys
if the tbl_part table’s foreign key has not yet been designated, it can be designated by:

A

(SQL Server and MySQL)
alter table tbl_part
add foreign key (v_code) references tbl_vendor (v_code);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Adding Primary Key and Foreign Keys
if neither the tbl_line table’s primary key nor its foreign key has been designated, you can incorporate both changes at once, using:

A

(SQL Server and MySQL)
alter table tbl_line
add primary key (inv_number, line_number);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Deleting Table from Database, you can delete the PART table you just created with:
Syntax is : DROP TABLE tableName

A

(SQL Server and MySQL)
drop table tbl_part

How well did you know this?
1
Not at all
2
3
4
5
Perfectly