SQL First Talk

Source: Internet
Author: User

I. Overview of the database

1. Authentication Method at Login

Windows authentication

Mixed authentication pass very developed program using mixed authentication Mode

2. database file type

MDF Data Master File

Log file

3. Table structure

Cell data for a field to make up a table

A unique identification field for a data table set by a primary key

Data type

String Class Char/nchar,varchar/nvarchar

Integer class Bigint/int/smalint/tinyint

Floating-point number class Float/money/smalmoney/numeric

Date Time Class Date/datetime/smaldatetime

Switch class bit---1 is true, others are false.

4, the operation of the database frequently encountered problems

It is possible to restart the database service when the database is in use by another user. Right-click on the---database connection and select "Restart" in the menu that appears.

5. Query statements

SELECT * FORM stuinfor * denotes all fields

SELECT stuid,age FORM Stuinfor If you want to query some fields, you can give the desired field list directly.

WHERE query criteria can get records that satisfy query criteria

The ORDER BY field list ASC is a small-to-large sort (default), and Desc is sorted by a large variable--in reverse order.

The fields in the GROUP By Field List Field list must appear in the field list of the Select

Having query conditions He is a query condition used with GROUP by

6. Query condition Relationship

Like fuzzy query

In contains query

=/>/</>=/<= comparison character

7. Functions that can be used in the field list

COUNT (*) Record Count

SUN (field name) gets the total of the specified field, and of course the specified field must be numeric before it can be summed.

Min (field name) gets the minimum value in the specified field.

Max (field name) gets the maximum value in the specified field.

AVG (field name) gets the average of the specified field.

....

Second, joint inquiry

1. Left Association

Left Join table to establish query union

2. Right Association

Right Join left table primarily establishes query union

3. Bidirectional correlation

The record of the Inner Join around the table will appear

Iii. restrictions on the field list

1, TOP Specify the number of records to extract

Example: SELECT TOP 2 * FORM stuinfor---Extract start two records

2, DISTINCT remove duplicate records

such as: SELECT DISTINCT age FORM stuinfor---Extract the ages of non-repetition

SQL First Talk

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.