What is the truncate command? 
Truncate is a command that returns the table back to the way we first created it.
So it is a command that deletes all the data in our table as if we rebuilt this table from scratch.
Now you will say that DELETE command was also used to delete. What is the difference between this and that?
When we say delete from, it doesn't bring our table back to what we first created. In other words, if we have an auto-increasing area, for example, if I deleted a thousand records, when I added it again after deleting it, it continues from where it left off, ie 1001, and while the truncate process is a very fast process, delete is not so fast. If we want to completely empty the table, we use the truncate command instead of the delete command. In terms of both restoring our painting and being faster.
Let's explain with examples.

Our code will look like this: NAME OF YOUR TRUNCATE TABLE TABLE

First, write our select * from table name and call our table. Let's see what's inside.

Now let's apply our TRUNCATE command.
WE WRITE THE NAME OF OUR TRUNCATE TABLE TABLE .
THERE IS A SUBJECT THAT WE NEED TO KNOW THAT WE ARE USING TABLE, NOT FROM.
We wrote our code, now let's see how our table was.

As you can see, our painting has taken its original form. If I add a new record it will start at 1.
But if I deleted it with delete, it would start from where it left off.
This lesson is a success for everyone.

Yorum Yap

Daha yeni Daha eski