The last time you learned to add a field to a table in a database, let's continue to learn
--Modify a column field in a database table
Use database
ALTER TABLE name ALTER COLUMN type
--How to delete a column field in a database
Use database
ALTER TABLE table name drop column name
--Delete a table in the database
Use database
DROP table Name
Inserting data into a table in a database use database
Use database
Insert into table name (column 1, column 2) VALUES (' column 1 value ', ' column 2 value ') --Add different types of data to different columns based on column type
--Update a column field in the database
Use database
Update table name set column 1 name = ' column 1 value ', column 2 = ' column 2 value ' ..... --Update the values of individual or multiple columns at once, as appropriate
--The basic syntax of the SELECT statement and the conditional query are given below, because conditional updates are used later, in fact, where the condition is followed
Use database
SELECT * FROM table name -where the "*" indicates that all the field columns in the queried table are queried, and if only the query meets certain criteria, then the WHERE keyword is used
--If you query some fields of a table in the database (if we query the age field and the Name field in the table), then we can write
Use database
Select Age,name from table name --note that we've replaced the previous * number with a specific field that means we're querying some column fields instead of all the fields .
--such as querying all column information in a table, and age satisfies all information that is greater than 20, then we can write
Use database
SELECT * FROM table name where age>20
--Conditional UPDATE statement (for example, the class of the student with age greater than 20 in the Update table is Gao Iban)
Use database
Update table name Set class = ' Sophomore class ' Where Age >20
--Next we will learn a complex UPDATE statement, SQL statements with operations, update the age of AGE=20 students by default + 1 years old, then we can write
Use database
Update table name set age=age+1 where Age=20 -where age=age+1 is age on the original basis +1
--Delete all data from a table in a database
Use database
Delete from table name
--Delete a record in the database, or delete some records that meet the criteria
Use database
Delete from table name where age>21--deletes all records of the table name age greater than 21
SQL Server 2008 second day of learning