Use SQL to make simple additions and deletions to the database

Source: Internet
Author: User

1. Create a table

CREATE TABLE Table name (

The type of column names,

The type of column names,

Type of column name (note that the last column cannot be added ' ,')

);

2. Modify the table

Modify table Name--"Rename old table name to new table name;

Add column--"ALTER TABLE name Add (type of column list);

Modify column--"ALTER TABLE name modify (Type of column list);

Delete Column--"ALTER TABLE name drop (column name);

3. Display table structure

DESC table name;

4. Inserting data into the table

Insert Data-"INSERT into table name (column name, column name, column name) values (data, data, data); Note that data inserted in addition to numbers must be enclosed in single quotes '

Insert date data--"Eg:insert into EMP (birth) VALUES (' 2014-08-04 ', ' yyyy-mm-dd ');

5. Change the data in the table

Updated data (update)--"eg:update emp set salay=6500,job= ' clear ' where id = 1003;

Delete data (delete)--"Eg;delete from emp where id = 1003;

Delete from the EMP where job is null; (null value is in IS)

Use SQL to make simple additions and deletions to the database

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.