', ' 95 ', ' running ') 7. Query average score?Select AVG (score) as average scoreFrom Student-18. Query the surname Zhang?SELECT * FROM Student-1Where name like ' Zhang% '9. Use truncate to delete all dataTRUNCATE TABLE Student-1 Write so many examples just hope that everyone ingenious, this case is a student score table to do the demonstration, in exchange for other tables, the syntax is the same, this article is just a basic T-
The schema ID of the object owner.For databases upgraded from the old version of SQL Server, the schema ID is equal to the owner's user ID.Important:If you use any of the following SQL Server DDL statements, you must use the SYS.
1. System Table sysobjects
Each object (such as constraints, default values, logs, rules, and stored procedures) created in the database corresponds to a row.
Object ID number
Object type. It can be one of the following object types:AF = aggregate function (CLR)C = CHECK ConstraintsD = DEFAULT value or DEFAULT ConstraintF = foreign key constraintL = LogFN
(1) system table: stores all SQL system information. The metadata stored in the database service is called metadata (for example, the user databases on the data server, the login accounts on the database server, and
(1) system table: stores all SQL system information. The me
user account (or the corresponding ID of the account ). When other users log on to the system, the system first queries from this temporary table to check whether the same user records exist. If yes, the user will be rejected and the user will be warned that the same user has logged on. When the user exits the system normally or ends the current session due to other reasons, the database system will clear the contents of this table. In this way, you can log on to the system even if you log on t
-- Delete Table----------------------------------------------------------------------------------To add a constraint:ALTER TABLE Table name ADD CONSTRAINT constraint name constraint type specific constraint description1. The naming rules for constraint names are recommended in the form of constraint type _ constraint name.----------------------------------------------------------------------------------To delete a constraint:There are two ways to add a constraint to a specified tabl
Two tables linked to different libraries in the same server
This approach is limited to databases on the same server.I. Establishment of two databases, library a (table a) and Library B (table B).Second, to two libraries to assign the same account permissions.Use the following statement when querying:
A Left JOINIntfsimsnew. SYSOBJECTS B onA.name = B.nameWHEREISNULL (B.name,"') ="' andA.xtype =' U 'ORDER by 1,2--Compare the differences of each table field in two databasesSELECTTable name A = Case whenISNULL (A.tablename,"') "' ThenA.tablenameELSEB.tablenameEND, field name A = a.fieldname, field name B = b.fieldname, order = a.fieldsno, Description = Case whenA.fieldtype Then ' type: '+ A.fieldtype +' --'+ B.fieldtype whenA.fieldsno Then ' Order: '+ STR (A.FIELDSNO) +' --'+ STR (B.FIE
server| Create | stored Procedure | dynamic | data | database
The following are ways to create databases, tables, stored procedures, views, indexes, rules, modify tables, view data, and so on, using SQL statements. The controls you want to add are as follows:
The database->ssmstest-> table there, you will find the three tables that have just been created.(Select Database->ssmstest-> table->dbo.student Right-click to select the design to see the details of the table you just created.) ） 3.2 Creating tables with SQL statements 3.2.1 Select Database->sqltest, and then select New Query. Notice the box in the upper left c
I. Querying the database (Sys.databases--select *from sys.databases where name= ' Select *fromwhere name='MyDatabase'Second, query table (sysobjects--select *from sysobjects where id=object_id (' Select *fromwhere id=object_id ('studentsinfo')Third, query column (Syscolumns--select COUNT (*) from syscolumns where name= ' Select from where name='sname' and id=object_id ('studentsinfo ')Iv. querying a stored procedure or view (SELECT * from sysobjects where name= '
@ whereand parameter can narrow the output range according to the filter.
You can also add an order by statement. In the following example, the number of rows in each data table in the AdventureWorks database is returned and sorted by data indication:
exec sp_MSForEachTable@command1 = "Print '?'", @command2 = "select count(*) from ?", @whereand = "ORDER BY 1"
The following are some output results:
In special cases, the sysaltfiles primary database contains the rows corresponding to the files in the database. The table is stored in the master database.Each character set in the syscharsets primary database occupies one row in the table. The table also contains the definition for Microsoft? SQL Server? The sort order used. One of the sorting orders is marked as the default sorting order in sysconfigures
Use SQL statements to create school databases (including parameters), tblclass tables, and tblstudent tables. And fill in the data.
Create a school database (including parameters)Create Database SchoolOn Primary(Name = 'school ',Filename = 'f: \ SQL
TF = SQL Table-valued function
U = table (user-defined type)
UQ = UNIQUE Constraint
V = view
X = Extended Stored Procedure
IT = Internal table
I've introduced sysobjects this system table before. Custom tables, stored procedures ..... will be stored in this form.
" and enter the corresponding port number
SQL database Synchronous replication
I. Establish a publishing and distribution server
[Welcome to the Configure Publishing and Distribution Wizard]->[Select Distributor]
->[makes "@servername" its own distributor, SQL Server creates distribution
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:
and provide relevant evidence. A staff member will contact you within 5 working days.