Common standard SQL statements

1. The statement to create a database is as follows: create database databasename the above statement creates a database named databasename 2 The statement to delete the database is as follows. Drop database databasename the above statement will delete databasename database 3 The format of creating a table is as follows: create table tablename (column1 datatype [column_constraint], column1 datatype [column_constraint],... [constraint primary key pk_table_name (column_n)] take SQLSERVER database as an example, use SQL statement to insert the user table user, which has ID, name, password, The data types of email, age, birthday and money fields and fields in the database are int, varchar, varchar, int, datetime and float respectively. Since user is a keyword in the SQL Server database, users are not allowed to use it directly, so []         create table [user] (id int,name varchar(50),passworld varchar(50),email varchar(50),age int,birthday datetime); 4. The statement to delete a table is as follows: drop table tablename; The following statement is used to delete the table user.     drop table [user]; 5. The format of the statement to insert a record is as follows: insert into tablename (column1, column2,...) values (value1,value2,...); Insert a record into the user table.     insert into [user] (name,passworld,email,birthday)     values ('Funson','888',' Funson@163.com ',28,'1988-12-08',66.0); 6. Delete one or more records that meet the conditions: delete from tablename [where..]; Delete the record with ID 1 in the user table delete from user where id = 1; If you remove the where clause, all records in the user table will be deleted. 7. Update one or more records update tablename set columnname = newcolumnvalue; In the following statement, update the passworld field with id = 1 in the user table. The original value of the field is 123 and the updated value is 456. Update [user] set passworld = '456'

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>