There is no such thing as what you are thinking about. The database is a data storage and query mechanism. You don’t establish how it will be stored, that’s his problem to do, the data is just there, no matter how. You enter what you need and it’s over, it doesn’t have the slightest relevance as it was inserted.
When you consult you need to say how you want the results to come back. Carrying the secret is in SELECT
, there you will tell how the information is brought to you.
The question does not give details to help better, but it would probably be something like this:
SELECT * FROM tabela ORDER BY id DESC;
Behold working in the SQL Fiddle. Also put on the Github for future reference.
If you have a column called id
which is auto-incremented. That’s usually how it does it. If you don’t have a column with a value that is guaranteed to be in ascending order you can’t do what you want in Mysql, this is probably a mistake anyway. Creating an index to better handle this order can be key to maintaining good performance on bases with many lines.
that way whenever I go to add a new person I need to use this command there is how I leave permanently in DESC?
– Kleyner
@Kleyner actually has nothing to do with
inserir
user and yes at the time of the query. You will enter the data normally, without worrying about any order, at the time of displaying the dataselect
, that you will use theDESC
, thus, the results will be displayed in descending form. I conclude by reaffirming: Do not worry about the order that records are entered, the important thing is to pull this data from the database.– Jorge.M