These days to learn the company's system data flow. It mainly involves several tables of data. However, the data in the table is millions, so if there is no conditional SQL statement, it will cause the query card to die, and even a memory overflow situation. The database used by the company is SQL Server, so the following SQL
SQL statement to query the SQL Server name and IP address, SQL Server
Get Server Name:
SELECT SERVERPROPERTY('MachineName')select @@SERVERNAMEselect HOST_NAME()
To obtain the IP address, run the ipconfig command in xp_cmdshell:
-- Enable xp_cmdshell exec sp_configure 'show advanced options', 1 reconfigure with overrid
SQL statement to query the memory usage of SQL Server, SQL Server
SELECT type, -- Clerk type sum (bytes) as vm_Reserved_kb, -- reserved memory sum (bytes) as vm_Committed_kb, -- Submitted memory sum (awe_allocated_kb) as awe_Allocated_kb, -- the memory used after AWE is enabled sum (bytes) as sm_Reserved_kb, -- shared
, The value of this field is indeterminate, according to the workflow of the previous write, where the action time is done before the calculation, and having is calculated after the function, so in this case, the results will be different. On a multi-table join query, on has an earlier effect than where. The system first synthesizes a temporary table based on the conditions of the joins between the tables, then the where is filtered, then calculated, and then filtered by having. Thus, to filter
indeterminate, according to the workflow of the previous write, where the action time is done before the calculation, and having is calculated after the function, so in this case, the results will be different. On a multi-table join query, on has an earlier effect than where. The system first synthesizes a temporary table based on the conditions of the joins between the tables, then the where is filtered, then calculated, and then filtered by having. Thus, to filter the conditions to play the r
MySQL is the most basic SQL syntax. For more information, see.
The most basic SQL syntax/Statement of MySQL. For more information, see.
DDL-Data Definition Language (Create, Alter, Drop, DECLARE)
DML-data manipulation language (Select, Delete, Update, Insert)
DCL-Data Control Language (GRANT, REVOKE, COMMIT, ROLLBACK)
First, we will briefly introduce the basic
ddl-Data Definition language (create,alter,drop,declare)
dml-Data Manipulation Language (Select,delete,update,insert)
dcl-Data Control Language (Grant,revoke,commit,rollback)
First, briefly introduce the underlying statement:
1, Description: Create a database
Create DATABASE Database-name
2, Note: Delete the database
Drop Database dbname
3, Description: Backup SQL Server
Device to create backup data---
SQL Server SQL statement Import and ExportOverview: SQL statements of the Microsoft SQL Server database are imported and exported, including data imported and exported with other databases and files.
/*** Export to excelExec master.. xp_mongoshell 'bcp settledb. DBO. shang
Some commonly used SQL statement syntaxes compiled by Sanlian xiaobian. For more information, see the next section. data Control Statement (DML) Part 1. INSERT (statement for inserting records into the data table) INSERTINTO table name (field name 1, field name 2,) VALUES (value 1, value 2,); INSERTINTO table name (fie
Server Database SQL statement Import and Export Daquan, including the import and export of data with other databases and files.
/****** Export to excelExec master.. xp_mongoshell 'bcp settledb. DBO. shanghu out c: \ temp1.xls-C-Q-s "gnetdata/gnetdata"-U "sa"-P ""'
/*********** Import ExcelSelect *From OpenDataSource ('Microsoft. Jet. oledb.4.0 ','Data source = "C: \ test.xls"; user id = admin; Password =; e
based on Simple SQL Statement of SQL analytic principle and its application in big Data Li Wanhong SQL parsing is usually based on the analysis of Lexandyacc . , is the character by the analysis, performance is not high, if the analysis based on the SQL
Select top * from test where textdata are NOT null ORDER by duration DESC
This can choose a long run of the statement, in order by can be replaced by the CPU, reads, to select the CPU takes a long time and read too much data statements.
After you locate the offending statement, you can analyze it concretely. Some statements can clearly see the problem in the execution plan.
Common there is no index or inde
Introduction
Sp_who2 is a well known utility that shows what spids are currently executing. however the information it shows is relatively limited. for example, it only shows the type of command executing as select, delete etc, with no reference to the actual underlying SQL executing.
Knowing what SQL is executing can be vital in debugging why a query is taking a long time, or determining if it is being blo
Dear Boss:
I have a query for the SQL statement to consult, I hope to be able to get results with a SQL statement, the problem is as follows:
Table x:
A B C D
------------------
BEIJING Guangzhou 1000 10
Beijing Shenzhen 1200 20
Beijing Shanghai 500 30
Beijing Tianjin 300 40
Beijing Henan 800 20
Table y:
A B
-------
(1) Try to select smaller columns;(2) to index the more frequent fields in where;(3) Avoid using * in select;(4) Avoid the use of calculations, not-in and (5) Use limit1 when only one row of data is needed;(6) To ensure that the single-table data does not exceed 200w, real-time partition table;For a slow query, you can use explain to analyze the statement's specific execution.How do you describe how SQL statement
Tags: related use normal constant age order Date Res exampleSQL common additions and deletions change the statement 1 increase 1.1 "Insert single line"Insert [into] Example: INSERT into strdents (name, gender, date of birth) values (' Happy friends ', ' Male ', ' 1980/6/15 ') 1.2 "Add an existing table data to a table that already exists"INSERT into Example: INSERT into Tongxunlu (' name ', ' address ', ' email ')Select Name,address,emailFrom Strdents
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.