Home > database >  "DELETE * FROM table_name" is a syntax error?
"DELETE * FROM table_name" is a syntax error?

Time:08-12

I can't use

DELETE * FROM table_name

in MySQL / SQL Server / Oracle, but I read some blog it show me how to use DELETE * FROM table_name. So I can't use it that it's my problem?

CodePudding user response:

You should use 'DELETE FROM table_name', * is implicit because you can't delete only some columns.

CodePudding user response:

In the case when you need to delete everything, this query will do:

'DELETE FROM table_name'

The * is needed when you delete specific values for specific columns in a table.

Also, if you need to delete all table contents, you may also just delete the whole table, which is called 'dropping' a table.

More info about deleting in SQL here https://popsql.com/learn-sql/mysql/how-to-delete-in-mysql

CodePudding user response:

It is always a good idea to get the right syntax whenever there is a syntax error. For your Use Case,

DELETE FROM table_name;

You may further read about this here

CodePudding user response:

In Oracle or SQL Server you can simply use Delete table_name.

In MySQL or PostGre from clause is mandatory.

  •  Tags:  
  • sql
  • Related