Create an SQL statement _ interview

Source: Internet
Author: User

Creating a table: Create table if not exists teachaers (tea_id integer primary key autoincrement,tea_name Text,tea_gender Text,tea_age Interger,tea_salary text)

Primary KEY Primary Key


CREATE table if not exists teachaers (tea_id integer primary key autoincrement,tea_name Text,tea_gender text,tea_age Inter  Ger,tea_salary text) Primary key primary key distinguishes each piece of data, so the value of the primary key in development is unique and does not agree to have the same two values present. AutoIncrement the property value of the self-increment modifier adds one on its own at each time the data is added.

Insert data: INSERT INTO Teachaers (Tea_name, Tea_gender,tea_age,tea_salary) VALUES ("XX", "X", 20,xxxx)


Querying data


Query all data: SELECT * from Teachaers


Querying a single piece of data: SELECT * from teachaers where tea_id = 2


Querying data for multiple criteria: SELECT * from teachaers where tea_gender = "female" and tea_age = 25


Querying part of the data: Select Tea_name, tea_salary from teachaers where tea_id = 2


Delete an element in a table: delete from teachaers where tea_id = 2


Update a section of a database

Update teachaers Set tea_name = "Cai Cai", tea_age =27 where tea_salary = 130000


Delete a table

DROP table Name


Create an SQL statement _ interview

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.