1. Description: database creation tutorialCreate database-name2. Description: delete a database.Drop database dbname3. Description: Back up SQL server--- Create a device for the backup dataUse masterExec sp_addumpdevice 'disk', 'testback', 'c: mssql7
Simple view creation, deletion, preview, and other operationsA view is a virtual table whose content is defined by the query. Like a real table, a view contains a series of columns and row data with names. However, a view does not exist in the form
The illegal mix of collations (gbk_chinese_ci, implicit) appears when saving data in the mysql tutorial)
Other such problems are easy to solve, that is, the data submitted on the page is inconsistent with the mysql field type, as long as they are
CaseCalculate the condition list and return one of multiple possible result expressions.
Case has two formats:
The simple case function compares an expression with a group of simple expressions to determine the result.
The case search function
Merge and sort the records of multiple tables as follows:
Select * from (select * from Table
UnionSelect * from Table B
UnionSelect * Table c) as h order by h. List desc
In the database tutorial, the union and union all keywords combine
Two Methods for SQL to calculate the intersection of two tables
Dept table
Id deptid1 202 203 20
User table
Id userid1 332 343 34
Method 1
Select distinct userid
From user u
Where id in (select id from dept where deptid = 20)
Example 1: The table has a primary key (a field that can be uniquely identified) and the field is of the numerical type.
Example 1 test data/* Table Structure */Drop table if exists 't1 ';Create table if not exists 't1 '('Id' int (1) not null auto_
The following is an example of using the case function to complete this function.
Case has two formats. Simple case functions and case search functions.-- Simple case Function
Case sex
When '1' then 'male'
When '2' then 'female'
Else 'others'
The LIMIT clause can be used to force the SELECT statement to return the specified number of records. LIMIT accepts one or two numeric parameters. The parameter must be an integer constant. If two parameters are specified, the first parameter
SQL union all syntaxTable Name: tableField: id username ytimeThe result to be implemented is:Query 1:Select top 5 * from table where id> 20 order by id ascQuery 2:Select top 5 * from table where id Then, the sum of query 1 and query 2 is sorted in
Mysql tutorial group by, sorting the records with the largest time in each record
Select a. * from test,(Select aid, max (day) max_day from test group by aid) BWhere a. aid = B. aid and a. day = B. max_dayOrder by a. install desc
Test SQL
Create
Mysql tutorial log cleanup and mysql Log Analysis
SET NOCOUNT ONDECLARE @ LogicalFileName sysname,@ MaxMinutes INT,@ NewSize INTUSE tablename-name of the database tutorial to be operatedSelect @ LogicalFileName = 'tablename _ log',-log File Name@
Update statement
The Update statement is used to modify data in a table.Syntax:
UPDATE table name SET column name = new value WHERE column name = A ValuePerson:
LastName
FirstName
Address
City
Gates
Bill
In the SQL SQL Aggregate functions that use the same number of statements together provide some database tutorial columns for grouping (the result dataset method ).GROUP
The best way to use SQLGROUPStatement example.
The following database table
SQL union syntax and Examples
SQL union allows you to query the results of two or more individuals. The consortium is different because queries are subqueries that are independent from each other. The Consortium combines these individually selected
Three methods to return the record id after inserting a record in the mysql tutorial
Method 1
Id int (11) not null pri key auto_increment, name varchar (12), backup varchar (50)Now, when you want to insert a record, return its id value (only the
Mysql tutorial Regular Expression query and instance ^ Match the start part of the string$ Match the end part of a string$ SQL = "SELECT 'fonfo 'regexp '^ fo $' from string_find "; . Match any character (including carriage return and new line)$ SQL =
Concat Concat_ws
Mysql SQL character connection function Concat Concat_ws1. Concat () function1.1 The concat function of MySQL can connect one or more strings, suchMysql> select concat ('10 ');+ -------------- +| Concat ('10') |+ -------------- +| 10
The group by clause allows an additional row to be added to the simple output end WITH the ROLLUP modifier. These rows represent high-level (or high aggregation) simple operations. ROLLUP allows you to answer questions from the perspective of
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