国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Home Database Mysql Tutorial Getting Started with SQL Server 7.0 (1)

Getting Started with SQL Server 7.0 (1)

Dec 24, 2016 pm 05:35 PM
server sql

Interactive SQL (Transact SQL, TSQL)
It is the query language of SQL Server. The following commands are provided:
· Create and database objects.
· Access and modify data.
· Data aggregation (also known as aggregation).
· Implement safety measures.

Database Objects
Database objects are physical objects in the database. These objects have unique names and hold data and data relationship information. SQL Server defines the following objects:
1. Table (table)
A table is a two-dimensional array used to store data. It has rows and columns. Columns are also called table attributes or fields. Each column in the table has a unique name. Each column contains a specific data type. This data type is defined by the data type in the column.
2. View
A view is a virtual table, which only contains part of the table. Unlike a table, the data saved in a view is not physically stored data. It is derived from the table. The derived table is called the base table of the view. The definition of the view is stored in the database.
3. Constraints
Constraints define the integrity and validity of data. Constraints establish rules for the values ??in a column. In other words, if an end condition is defined on a column, every value inserted into that column needs to pass the constraint check. Constraints are a better choice for ensuring data integrity and validity on triggers and rules. SQL Server Query Optimizer uses constraints to generate low-cost query plans. Constraints are of the following types:
· NOT NULL This constraint requires that there cannot be NULL values ??in the column.
· CHECK Checks the constraints after specifying the set of values ??that the column can have. Any data in the column that is outside the definition is invalid data. The set of valid values ??is called the domain of the column.
· PRIMARY KEY The primary key is a column or column combination, which is used to uniquely identify a row.
· FOREIGN KEY is used to define the parent-child relationship between two tables. If a key is part of the primary key of one table and the primary key of another table, it is called a foreign key. Foreign keywords are used to define the referential integrity of data.
· UNIQUE The unique constraint means that no two rows have the same NON-NULL value in the column. Uniqueness is guaranteed by primary keys, but they do not allow NULL values, and there can be only one key per table.
4. Default value (default)
The default value is the value defined for the column. If the value of a column is not provided when inserting a row, the default value is used for this column. The default value can be one of the following:
·Constant
· Mathematical expression
· Internal function (Built-in function)
5. Rule (rule)
Rule execution has the same function as CHECK constraints. But the difference between rules and constraints is that rules exist as independent objects and can be used in multiple tables, while constraints are stored as part of a table. However, the rules are provided as a backwards compatibility feature and users are advised to use constraints.
6. Triggers and stored procedures
Triggers and stored procedures are a set of TSQL commands, which are stored in the database as an object.

Object naming convention
SQL Server uses a three-part name to identify objects:
..
The first two parts can be omitted, The system has a default value. The default value for the database name is the current database, and the default value for the owner name is the database owner (dbo).

Data type
Any object containing data has a data type associated with it. Data types are properties that specify what kind of data an object can contain.
?????? SQL Server data type
Data type
said
Synonyms

Bit
1 bit, the value is 0 or 1
Int

Integer
4 bytes, the value is -2^31~2^31-1


Smallint
2 bytes, the value is -2^15~2^15-1


Tinyint
1 byte, the value is 0~255


Decimal (p,s)
Number data, fixed precision is P , the width is S
Numeric

Money
8 bytes, the currency type is stored, the value is -2^63~2^63-1


Small money
4 bytes, the currency type is stored, the value is -214748.3648~+ 214748.3647 Approximate numerical data type


Float (n)
N is between 1~24, 4 bytes, 7-bit precision
N=1~7 is real


N is between 25~53, 8 bytes , 15-digit precision
=8~15 is float

Datetime
8 bytes, describing the date and time of a certain day, the accuracy of the value is 1/300 second


Smalldatetime
4 bytes, describing the date of a certain day and time, precision is minutes


Cursor
Reference to cursor


Timestamp
8 bytes, stored in the database unique data


Uniqueidentifier
16 bytes, stored globally unique identifier (GUID)


Char (n)
Fixed length of non-unicode string, n=1~8000
Character (n)

Varchar (n)
Variable length, non-unicode string n=1~8000
Char varying(n)

Text
Variable-length non-unicode data in the server code page. The maximum length is 231-1 characters


Nchar
Fixed length unicode string n=1~4000
National character (n),
National char(n)

Nvarchar
Fixed length unicode string n=1~4000
National character varying(n)

Ntext
Variable length unicode data, the maximum length is 230-1 characters
National text

Binary (n)
Fixed length binary data, n is between 1~8000, storage space is n+4 bytes


Varbinary (n)
Variable length binary data, n=1~8000
Binary varying (n)

Tmage
Variable length binary data, size is 0~231-1


Note:
1) For numeric data types, the width (scale) refers to the number of digits stored after the decimal point, and precision (precision) refers to all the number of digits that can be stored including the decimal point.
2) The storage width of money and small money is 4.
3) The timestamp column value is automatically updated by the system when each row is updated. The timestamp column cannot be a keyword or part of a keyword.
4) The unique identification data type cannot use arithmetic operators (such as +, -, etc.). This data type can only use equality comparison operations. Unicode is a standard for storing data consistently across all character sets. It uses twice the storage space of non-Unicode data storage.

The above is the content of Getting Started with SQL Server 7.0 (1). For more related content, please pay attention to the PHP Chinese website (www.miracleart.cn)!


Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

PHP Tutorial
1502
276
SQL: The Language, MySQL: The Database Management System SQL: The Language, MySQL: The Database Management System Apr 21, 2025 am 12:05 AM

The relationship between SQL and MySQL is: SQL is a language used to manage and operate databases, while MySQL is a database management system that supports SQL. 1.SQL allows CRUD operations and advanced queries of data. 2.MySQL provides indexing, transactions and locking mechanisms to improve performance and security. 3. Optimizing MySQL performance requires attention to query optimization, database design and monitoring and maintenance.

MySQL: A Practical Application of SQL MySQL: A Practical Application of SQL May 08, 2025 am 12:12 AM

MySQL is popular because of its excellent performance and ease of use and maintenance. 1. Create database and tables: Use the CREATEDATABASE and CREATETABLE commands. 2. Insert and query data: operate data through INSERTINTO and SELECT statements. 3. Optimize query: Use indexes and EXPLAIN statements to improve performance.

SQL vs. MySQL: Clarifying the Relationship Between the Two SQL vs. MySQL: Clarifying the Relationship Between the Two Apr 24, 2025 am 12:02 AM

SQL is a standard language for managing relational databases, while MySQL is a database management system that uses SQL. SQL defines ways to interact with a database, including CRUD operations, while MySQL implements the SQL standard and provides additional features such as stored procedures and triggers.

Comparing SQL and MySQL: Syntax and Features Comparing SQL and MySQL: Syntax and Features May 07, 2025 am 12:11 AM

The difference and connection between SQL and MySQL are as follows: 1.SQL is a standard language used to manage relational databases, and MySQL is a database management system based on SQL. 2.SQL provides basic CRUD operations, and MySQL adds stored procedures, triggers and other functions on this basis. 3. SQL syntax standardization, MySQL has been improved in some places, such as LIMIT used to limit the number of returned rows. 4. In the usage example, the query syntax of SQL and MySQL is slightly different, and the JOIN and GROUPBY of MySQL are more intuitive. 5. Common errors include syntax errors and performance issues. MySQL's EXPLAIN command can be used for debugging and optimizing queries.

SQL in Action: Real-World Examples and Use Cases SQL in Action: Real-World Examples and Use Cases Apr 18, 2025 am 12:13 AM

In practical applications, SQL is mainly used for data query and analysis, data integration and reporting, data cleaning and preprocessing, advanced usage and optimization, as well as handling complex queries and avoiding common errors. 1) Data query and analysis can be used to find the most sales product; 2) Data integration and reporting generate customer purchase reports through JOIN operations; 3) Data cleaning and preprocessing can delete abnormal age records; 4) Advanced usage and optimization include using window functions and creating indexes; 5) CTE and JOIN can be used to handle complex queries to avoid common errors such as SQL injection.

Getting Started with SQL: Essential Concepts and Skills Getting Started with SQL: Essential Concepts and Skills Apr 22, 2025 am 12:01 AM

SQL is a language used to manage and operate relational databases. 1. Create a table: Use CREATETABLE statements, such as CREATETABLEusers(idINTPRIMARYKEY, nameVARCHAR(100), emailVARCHAR(100)); 2. Insert, update, and delete data: Use INSERTINTO, UPDATE, DELETE statements, such as INSERTINTOusers(id, name, email)VALUES(1,'JohnDoe','john@example.com'); 3. Query data: Use SELECT statements, such as SELEC

Where to start writing SQL code? How to start writing SQL code? Guide to starting point of writing SQL code? Where to start writing SQL code? How to start writing SQL code? Guide to starting point of writing SQL code? Jun 04, 2025 pm 07:27 PM

The starting point of writing SQL code is to clarify the requirements. 1) Understand the problem you want to solve and determine the relationship between the required data and tables. 2) Start designing queries from simple SELECT statements and gradually increase complexity. 3) Use visualization tools to understand table structure and consider using JOIN when queries are complex. 4) Test the query and use the EXPLAIN command to optimize performance to avoid common pitfalls such as NULL value processing and inappropriate index use.

SQL's Versatility: From Simple Queries to Complex Operations SQL's Versatility: From Simple Queries to Complex Operations May 05, 2025 am 12:03 AM

The diversity and power of SQL make it a powerful tool for data processing. 1. The basic usage of SQL includes data query, insertion, update and deletion. 2. Advanced usage covers multi-table joins, subqueries, and window functions. 3. Common errors include syntax, logic and performance issues, which can be debugged by gradually simplifying queries and using EXPLAIN commands. 4. Performance optimization tips include using indexes, avoiding SELECT* and optimizing JOIN operations.

See all articles