A table named Student contains the following fields: id, classid, name, birth, remark
1. Insert a record: classid = 2 name = Zhang San birth = 1982-07-19;
Answer: insert into student (classid, name, birth) values (2, 'zhang san', '2017-07-19 ')
2. Select all students whose classid is 4;
Answer: select * from student where classid = 4
3. query all persons with the Year of birth greater than 1976;
Answer: select * from student where birth> '123'
4. query the number of people who have been born in each class for more than 1976 years;
Answer: select classid, count (*) as number from student where birth> '123' group by classid
5. query the number of students in all classes;
Answer: select classid, count (*) as total from student group by classid
6. query all records containing "Plans" in the REMAK;
Answer: select * from student where remark like '% scheduler %'
7. Improve SQL efficiency;
Answer: In ASP,
- Use JOIN to write complex SQL statements instead of a bunch of SQL statements: Query all data at a time;
- Use the UPDATE statement instead of rs. update ();
- Batch Processing of SQL statements is more efficient than executing one sentence;
- The where clause first considers the index;
- Avoid using large fields such as TEXT: Large execution efficiency is also high in the database;
Other aspects:
- Replacing temporary tables with embedded views: temporary tables consume a lot of memory and perform a lot of I/O operations;
- Avoid using left join and NULL values, Use inner join, and set the field cannot be NULL;
- Use indexes;
- Use the partition view;
- Use the trigger to run the stored procedure to another statistical table;
8. The code is used to print the triangle;
Answer:
Code
Private void PascalTriangle (int number)
{
Int I, j, n, m;
N = number;
Int [,] a = new int [20, 20];
For (I = 0; I <n; I ++)
{
A [I, 0] = 1;
A [I, I] = 1;
}
For (I = 2; I <n; I ++)
{
For (j = 1; j <I; j ++)
{
A [I, j] = a [I-1, j-1] + a [I-1, j];
}
}
For (I = 0; I <n; I ++)
{
For (m = 1; m <n-I; m ++)
{
Response. Write ("& nbsp ;");
}
For (j = 0; j <= I; j ++)
{
Response. Write (a [I, j]. ToString ());
Response. Write ("& nbsp ;");
}
Response. Write ("<br> ");
}
}