_3 to start learning SQL database

About Some examples of INSERT INTO

Previously the above table

I want to insert a row

then

  INSERT INTO Movies(Id, Title)

  VALUES(15,'Hua');

The other three values ​​are null

But if so

  INSERT INTO Movies wrote, it would default to include them all, so all have to write up the value of property

  VALUES(15, "Hua","Hua",2020,520);

Better yet, all add up, what property you want to add to what to write, even if you also want to add all

最好写成INSERT INTO Movies(Id, Title, Director, Year, Length_minutes)

 

Then is a UPDATE

UPDATE Movies

SET Director = "Hua", Year = 2020, Length_minutes = 520

WHERE Id = 15 // remember here is 15, instead of '15', here you have to remember to match right, otherwise all the property values in the tuple will be written into the above-Director = "Hua", Year = 2020 , Length_minutes = 520
remember with update and insert the time in the conditions written in adding up the table, or will direct hell broke loose

For example, if the direct write

  UPDATE Movies

  SET Director = "Hua", Year = 2020, Length_minutes = 520

That he is when you write these letters have all been updated,

So you should first write and then write the WHERE above SET

Plus a map

Then is the DELETE

Note that SQL DELETE statement WHERE clause!
WHERE clause specifies which record or records which need to be removed. If you omit the WHERE clause, all records will be deleted!

For example, to delete rows which just added

  DELETE FROM Movies

  WHERE Id = 15

To ok

If you want to delete all records

DELETE FROM table_name;



DELETE * FROM table_name;

Want to know more about and then delete operations go https://www.runoob.com/sql/sql-delete.html see note below chiefs on the line

Guess you like

Origin www.cnblogs.com/WildSky/p/11548517.html