Computer Science, asked by Toska982, 1 year ago

When we apply truncate command on a table's primary key is initialized?

Answers

Answered by golu00145
0
sql find error becoz primary key r intialized
Answered by hotelcalifornia
0

Answer:

When truncate command is applied on a table, its "primary key" is initialized.

This can be explained as follows:

1. "Truncate command" is used to "remove all records" from the table without deleting the structure of the table.

2. It is different from the "delete command" because "delete command" removes the records from the table but does not re-initialize it. Truncate command deletes records and re-initializes the table and its primary key.

3. Example: Consider a table which has a column which auto-incremental and is also is primary key, with 20 records. If delete command is executed on this table, it will delete all the rows and the next record inserted will have the value 21 in the auto-incremental primary key column. However, if truncate command is executed on this table, the next record inserted will have primary key column with value 1 i.e. it will be re-initialized.

Similar questions