As early as itpub saw a SQL expert, like the puzzle, the following is a puzzle. I tried SQL Server to resolve this issue.With 1 points,5 points , 10 points , 25 points , 50 cents coins into one yuan, a total of several combinations of methods? SELECT'1*'+RTrim(A. Number)+'+5*'+RTrim(b. Number)+'+
50 SQL Query Techniques, query statement examples, 50 SQL statements
Student (S #, Sname, Sage, Ssex) Student tableCourse (C #, Cname, T #) CurriculumSC (S #, C #, score) Orders tableTeacher (T #, Tname) Instructor tableProblem:1. query the student ID of all students whose score is higher than that of the "002" course;
/* Table scores has four fields: Student Stu, class, school institute, and score.
Returned results: the number of students in the class is greater than 10, the number of students in the class is higher than 50, and the average score of the Computer College and the class is from high to low.
You can use any database to write SQL statements. The returned fields a
50 methods to skillfully optimize your SQL Server database
There are many reasons for slow query speed. The following are common causes:
1. No index or no index is used (this is the most common problem of slow query and is a defect in programming)
2. Low I/O throughput, resulting in a bottleneck effect.
3. the query is not optimized because no computing column is created.
4. Insufficient memory
5. slow net
, increase the number of server CPUs; but it must be understood that parallel processing of serial processing requires resources such as memory. The use of parallel or serial stroke is the automatic evaluation of MSSQL selection. A single task can be run on a processor by breaking it into multiple tasks. For example, delays in sorting, linking, scanning, and group by words, SQL Server determines the optimal level of parallelism based on the load of th
proportional to the total length of the field value, so the char type is not used, but varchar. The full-text index is long for the value of the field.9, DB server and Application server separation, OLTP and OLAP separation.10. A distributed partitioned view can be used to implement a federation of database servers. A consortium is a set of servers that are managed separately, but they work together to share the processing load of the system. This me
/*Title: 50 SQL statements involved in a project (sorted Version)Author: AI xinjue Luo. Xin Hua)Time: 2010-05-10Location: Chongqing aerospace Vocational CollegeNote: The following 50 statements have been tested according to the test data. It is best to run only one statement at a time.Problem and description:-- 1. Student tableStudent (s #, sname, sage, ssex) --
time is proportional to the total length of the field value, so the CHAR type cannot be used, but VARCHAR. Create a full-text index for a long field value.
9. Separate DB Server and APPLication Server; Separate OLTP and OLAP
10. Distributed partition view can be used to implement Database Server consortium. A consortium is a group of separately managed servers, but they collaborate to share the processing load of the system. This mechanism of forming
the SQL problem. Use the index optimizer to optimize the index.17. Pay attention to the difference between Union and Union all. Good union all18. Use distinct unless necessary. Similar to union, it slows down the query. Duplicate records are no problem in the query.19. Do not return unwanted rows or columns during query.20. Use sp_configure 'query Governor cost limit 'or set query_governor_cost_limit to limit the resources consumed by the query. When
, consumption of space. Like ' a% ' uses the index like '%a ' when querying with like '%a% ' without an index, the query time is proportional to the total length of the field value, so the char type is not used, but varchar. The full-text index is long for the value of the field. 9. Separation of DB server and application server; OLTP and OLAP separation 10. A distributed partitioned view can be used to implement a federation of database servers. A co
50 commonly used test and interview SQL statements Postedon50 commonly used test and interview SQL statements 2009-12-1715: 05 Student (S #, Sname, Sage, Ssex) student table Course (C #, Cname, T #) Course list SC (S #, C #, score) Instructor table question: 1. query all students whose 001 course scores are higher than 002.
5
reduce the size of the table(Sp_spaceuse)3. Upgrading hardware4.indexing, optimizing indexes, and optimizing access based on query criteria,limit the amount of data in a result set。 Attentionfill factor to be appropriate(preferably using the default value of 0). The index should be as small as possible,use a Lie Jian index with a small number of bytesGood (refer to the creation of the index),do not have a limited number of valuesThe word Jianjian single index such as Gender field5, improve spee
50 tips for optimizing query: (see which one is suitable for you)
1. Place data, logs, and indexes on different I/O devices to increase the reading speed. In the past, tempdb can be placed on raid0, which is not supported by SQL2000. The larger the data size (size), the more important it is to increase I/O.
2. vertically and horizontally split the table to reduce the table size (sp_spaceuse)
3. upgrade hardware
4. Create an index based on the query co
stored procedure.
In particular, do not use nested views. nested views increase the difficulty of searching for original data. Let's look at the nature of the View: it is stored on the server.
The optimized SQL query plan has been generated. When retrieving data from a single table, do not use a view pointing to multiple tables.
You can retrieve or read the view that only contains the table. Otherwise, unnecessary overhead is added and the query is d
Http://www.buywork.cn/biancheng/database/ SQL /20071111/10840.html
There are many reasons for slow query speed. The following are common causes: 1. No index or no index is used (this is the most common problem of slow query and is a defect in programming) 2. Low I/O throughput, resulting in a bottleneck effect. 3. the query is not optimized because no computing column is created. 4. Insufficient memory 5. slow network speed 6. The queried data
This text has been reprinted online, and some SQL statements are suitable for use in application systems. Some "reports" have a heavier feeling, mainly to review the former.
This text has been reprinted online, and some SQL statements are suitable for use in application systems. Some "reports" are more likely to be used, mainly to review the former.
50 common
. Therefore, the char type cannot be used, but varchar is not used. Create a full-text index for a long field value. 9. Separate DB server and application server; Separate OLTP and OLAP 10. Distributed partition view can be used to implement Database Server consortium. A consortium is a group of separately managed servers, but they collaborate to share the processing load of the system. This form of database through partition dataThe server consor
50 SQL statements involved in one question
Student (s #, sname, sage, ssex) Student tableCourse (C #, cname, T #) CurriculumSC (s #, C #, score) Orders tableTeacher (T #, tname) Instructor table
Problem:1. query the student ID of all students whose score is higher than that of the "002" course;Select a. s # From (select s #, score from SC where C # = '001') A, (select s #, scoreFrom SC where C # = '002
50 Common SQL statements
Student (s#,sname,sage,ssex) Student table
Course (c#,cname,t#) timetable
SC (s#,c#,score) score sheet
Teacher (t#,tname) Teacher's Table
Problem:
1, Query the "001" Course than "002" course scores of all students of the school number;
Select a.s# from (select S#,score from SC where c#= ' 001 ') A, (select S#,score
From SC where c#= ' 002 ') b
where A.score>b.score and a.s#=b.s#;
50 commonly used SQL statements Student (S #, Sname, Sage, Ssex) Student table Course (C #, Cname, T #) curriculum SC (S #, C #, score) exam table Teacher (T #, Tname) Instructor table questions: 1. query the student ID of all the students whose scores are higher than those of the 002 course; selecta. S # from (selects #, scorefromSCwhereC #001)
50 commonly used
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.