Ms SQL Server type. Tipi data SQL. Two and two types of data

Golovna / Optimization of work

DESIGN OF THE DATA STRUCTURE

Power supply:

1. Types of data mov SQL, designated by the standard.

2. Tipi data, like in the SQL server. 3

3. Virazi and change. 5

4. Key constructions of SQL.

5. Main objects of the SQL server database structure. 7

Types of data mov SQL, designated by the standard

Dani- This is the total information that is collected in the database from one of the different types. For additional types of data, the basic rules for data are established, which are placed in a specific table column, including the memory expansion that is seen for them.

Mov SQL has six scalar data types defined by the standard. Їх a short description of the representations of the table.

Symbolic data

Symbolic data is composed of a sequence of symbols, which is included before the set of symbols sung by the creators of the DBMS. Other character sets specific to different dialects of SQL language, character translations, which can be included in the storage of data character types, as well as stored in a specific implementation. The most commonly used character sets are ASCII and EBCDIC. To assign data to a character type, the following format is used:

<символьный_тип>::=

( CHARACTER [ VARYING][long] | [long])

When set to a symbolic data type, the default value parameter is set to indicate the maximum number of characters that can be placed in this column (the value 1 is accepted for capturing). A character string can be assigned as such, which can be fixed or changed (VARYING) to a long time. Although the row is assigned with a fixed double value, then with the introduction of a smaller number of symbols in it, the value is supplemented to the specified double with right-handed spaces. If a row is assigned a changed old value, then with the introduction of a smaller number of characters in the database, it will be saved more than the entered characters, which will allow reaching the same economy of sound memory.

Bit data

Bit type danih vikoristovuetsya designation of battle rows, tobto. sequence of double digits (bіtіv), skin z of which may be either 0 or 1. Data of the bit type are assigned to the additional offensive format:

<битовый_тип>::=

BIT [dovzhina]

Exact numbers

Type of exact numeric data zastosovuєtsya vyznachennya numbers, yakі may be more accurate vyavlennya, tobto. numbers are added up from digits, a non-linguistic decimal point and a non-linguistic sign symbol. Data of the exact numerical type are determined by the accuracy and the long shot part. Accuracy sets the total number of significant tenth digits of the number, where to enter the dozhina as a whole part, and fractional, but not reverse the tenth point itself. The scale indicates the number of other tens of rows of the number.

<фиксированный_тип>::=

(NUMERIC[precision[,scale]]|(DECIMAL|DEC)

[accuracy[, scale]]

| (INTEGER|INT) | SMALLINT)

Tipi NUMERICі DECIMAL assigned for saving numbers in the tenth format. For zamovchuvannyam, the value of the shotgun part is equal to zero, and the accuracy, which is accepted for ablution, lies in the implementation. The INTEGER (INT) type is used to capture great positive or negative integers. The SMALLINT type is for taking small positive and negative integers; at this point of view, the old memory is quickly rushing.

Rounded numbers

rounded number type zastosovuetsya for the description of data, as it is not possible to accurately show on the computer, the actual numbers. Rounded numbers or numbers with a floating point are presented in scientific notation, with which number is recorded for an additional mantis, multiplied by the equal equal of ten (order), for example: 10E3, +5.2E6, -0.2E-4. For the designation of the speech type, the format is:

<вещественный_тип>::=

( FLOAT [accuracy] | REAL |

DOUBLE PRECISION)

Parameter accuracy determines the number of significant digits of the mantis. Accuracy of types REAL and DOUBLE PRECISION to be deposited in a specific implementation.

date that hour

Data type "date/hour" win the appointment of the moment at the hour with the established accuracy. The SQL standard supports this format:

<тип_даты/времени>::=

(DATE | TIME[precision]|

TIMESTAMP[precision])

The DATE data type is used to store calendar dates, which include the fields YEAR, MONTH, and DAY. The TIME data type is used to store the hour mark, which includes the fields HOUR (annual), MINUTE (hvilin) ​​and SECOND (seconds). The TIMESTAMP data type is for saving the date at that hour. The precision parameter sets the number of decimal places, which determine the accuracy of the saving value in the SECOND field. If this parameter is omitted, its value for columns of the TIME type is taken equal to zero (so whole seconds are saved), then for fields of the TIMESTAMP type it is taken equal to 6. The presence of the keyword WITH TIME ZONE is set to the same value of the fields MIN TIMEZONE HOUR and TIME date and time of the date of the zonal hour according to the date to the universal coordinate hour (Greenwich Mean Time).

Data of the type INTERVAL are awarded for the representation of periods of the hour.

Understanding the domain

Domain– the set of allowable values ​​of one or a number of attributes. As in the tables of the database or in the decal tables there are stovpts, which can be characterized by one and the same characteristics, it is possible to describe the type of such stovptsya and yogo behavior through the domain, and then put in the appearance of the same stovptsі in the name of the domain. The domain assigns all potential values ​​that can be assigned to an attribute.

The SQL standard allows you to designate a domain behind the help of an offensive operator:

<определение_домена>::=

CREATE DOMAIN name_domain

data type

[DEFAULT value]

[ CHECK (valid_value)]

The skin domain that is being created is assigned a name, a data type, a lock value, and a set of allowable values. Slid to indicate that the format of the operator is invalid. Now you can specify the time of table creation to change the data type of the name to the domain.

View of domains from the data base is conferred for the assistance of the operator:

DROP DOMAIN domain [ RESTRICT |

If the keyword CASCADE is entered differently, whether it is a table entry that matches the domain that you see, it will be automatically changed and the description will be changed to replace the given type, which is the name of the entry in the assigned domain.

An alternative to domains in the middle of SQL Server is the type of data koristuvach.

Types of data, which are victorious in SQL-server

System Data Types

One of the main points in the process of creating tables is the selection of data types for її fields. The data type of the table field determines the type of information to be placed in this field. The understanding of the data type in SQL Server is generally adequate to the understanding of the data type in modern programming language. SQL Server supports a large number of different types of data: text, numbers, binary (div. table).

Let's take a quick look at SQL Server data types.

For sberіgannya character information vikorivuyutsya character data types, until they lie CHAR (dovzhina), VARCHAR (dovzhina), NCHAR (dovzhina), NVARCHAR (dovzhina). Remaining two flags for taking Unicode characters. The maximum value is limited by 8000 characters (4000 Unicode characters).

Saving symbolic data of great extent (up to 2 GB) is required for additional text data types TEXT and NTEXT.

Before whole types of data INT (INTEGER), SMALLINT, TINYINT, BIGINT. To save data of a single type, it is possible to select, 4 bytes (range -231 to 231-1), 2 bytes (range -215 to 215-1), 1 byte (range 0 to 255) or 8 bytes (range range -231 to 231-1). -263 to 263-1). Objects of the same type can be stuck in some kind of mathematical operations.

Numbers, in which warehouses have tens of points, are called non-numerics. Non-integer data subdivided into two types - dozensі approx..

Before tenth The data type should be DECIMAL [(precision[,scale])] or DEC and NUMERIC [(precision[,scale])]. The DECIMAL and NUMERIC data types allow you to independently set the floating point number precision format. The precision parameter sets the maximum number of digits of data of this type (before and after the tenth point in the sum), and the scale parameter is the maximum number of digits that are added after the tenth point. In the default mode, the server allows you to enter more than 28 digits, like in the DECIMAL and NUMERIC types (for 2 to 17 bytes).

Before approximate data type is FLOAT (accuracy up to 15 digits, 8 bytes) and REAL (accuracy up to 7 digits, 4 bytes). Qi tipi represent these formats with a floating coma, tobto. for the representation of numbers, the mantis is victorious, that order, which ensures the same accuracy of calculation independently, since the number is small and large.

To collect information about give that hour such types of data are recognized, such as DATETIME and SMALLDATETIME, which are used to represent dates of that hour 8 and 4 bytes.

Tipi danih MONEY and SMALLMONEY encourage the saving of information of a penny type; stinks ensure the accuracy of the value up to 4 characters after the Komi and victorious 8 and 4 bytes are clear.

Data Type BIT allows you to save one bit, which takes the value 0 or 1.

SQL Server core has implemented a number of special types of data.

data type TIMESTAMP vikoristovuєtsya as an indicator of changing the version of the row in the boundaries of the data base.

data type UNIQUEIDENTIFIER win for the collection of global identification numbers.

data type SYSNAME assignments for object identifiers.

data type SQL_VARIANT allows you to save the value of any of the data types used by SQL Server TEXT, NTEXT, IMAGE and TIMESTAMP.

data type TABLE, similar to the timing tables, ensuring the safety of a set of rows, signs for further processing. The TABLE data type can be blocked by locally changing and rotating values ​​by local functions.

data type CURSOR It is necessary for working with such objects as cursors, and there may be requests only for changing the parameters of procedures that are saved. SQL Server cursors are a mechanism for data exchange between the server and the client. The cursor allows client programs to work not with a complete set of data, but with only one or a row of data.

Last update: 12.07.2017

When folding the tables of all the columns, it is necessary to indicate the type of data. The type of data is determined, which values ​​can be saved in the column, how many stinks can take up space in memory.

The T-SQL language has many different types. Depending on the nature of the value, they can be divided into groups.

Numerical types of data

    BIT: takes the value 0 or 1. In fact, it is an analog of the boolean type in programming language. Takes 1 byte.

    TINYINT: Takes numbers from 0 to 255. Takes 1 byte. It's good to go for taking small numbers.

    SMALLINT : take numbers from -32768 to 32767. Takes 2 bytes

    INT : takes numbers from -2147483648 to 2147483647. Borrows 4 bytes. The most common type of number saving.

    BIGINT : takes even large numbers like -9223372036854775808 to 9223372036854775807, which takes 8 bytes from memory.

    DECIMAL : Take numbers with a fixed precision. Borrows from 5 to 17 bytes indeterminately from the number of numbers after Komi.

    This type can take two parameters, precision and scale: DECIMAL(precision, scale) .

    The precision parameter represents the maximum number of digits that a number can take. The value may be in the range of 1 to 38. For locking it is more expensive 18.

    The scale parameter represents the maximum number of digits that can offset the number after Komi. This value may be in the range of 0 up to the value of the precision parameter. For zamovchuvannyam won't equal 0.

    NUMERIC: This type is similar to the DECIMAL type.

    SMALLMONEY : Takes a shot value from -214748.3648 to 214748.3647. Appointments for saving pennies. Takes 4 bytes. Equivalent to DECIMAL(10,4) .

    MONEY : saves shot values ​​from -922337203685477.5808 to 922337203685477.5807. Imagine pennies and it takes 8 bytes. Equivalent to DECIMAL(19,4) .

    FLOAT: takes numbers from -1.79E+308 to 1.79E+308. Borrow from 4 to 8 bytes fallow from the fractional part.

    You can use the FLOAT(n) , de n is the number of bits, so you can choose to save the tenth part of the number (mantis). Typically n = 53.

    REAL : Save numbers from –340E+38 to 3.40E+38. Takes 4 bytes. Equivalent to FLOAT(24) .

Apply numbers: Salary MONEY, TotalWeight DECIMAL (9,2), Age INT, Surplus FLOAT

Tipi danih sho represent the date that hour

    DATE: Save dates from 0001-01-01 (Saturday 1, 0001) to 9999-12-31 (Saturday 31, 9999). Takes 3 bytes.

    TIME : takes the hour from the range 00:00:00.0000000 to 23:59:59.9999999. Borrows 3 to 5 bytes.

    You can use the form TIME(n) , where n becomes the number of digits from 0 to 7 for fractional seconds.

    DATETIME : Save dates from 01/01/1753 to 31/12/9999. Takes 8 bytes.

    DATETIME2 : Takes the date and hour in the range from 01/01/0001 00:00:00.0000000 to 12/31/9999 23:59:59.9999999. Borrows from 6 to 8 bytes, depending on the accuracy of the hour.

    You can use the form DATETIME2(n) , where n becomes the number of digits from 0 to 7 for fractional seconds.

    SMALLDATETIME : Save the date and hour in the range from 01/01/1900 to 06/06/2079, which is the closest date. Borrows 4 bytes.

    DATETIMEOFFSET : Save the date and hour in the range 0001-01-01 to 9999-12-31. Takes detailed information about the hour with an accuracy of up to 100 nanoseconds. Borrow 10 b.

Extended date formats:

    yyyy-mm-dd- 2017-07-12

    dd/mm/yyyy - 12/07/2017

    mm-dd-yy - 07-12-17

    In this format, two-digit numbers from 00 to 49 are accepted as dates in the range 2000-2049. And the numbers from 50 to 90 are the range of numbers 1950 - 1999.

    Month dd, yyyy - July 12, 2017

Extended hour format:

  • hh:mi am/pm - 1:21 pm

    hh:mi:ss - 1:21:34

    hh:mi:ss:mmm - 1:21:34:12

    hh:mi:ss:nnnnnnn - 1:21:34:1234567

String types of data

    CHAR : Selects a string from 1 to 8000 characters long. On the skin, the symbol is seen by 1 byte. Not suitable for rich mov that take characters not encoded in Unicode.

    The number of symbols, which can be saved, is transmitted at the temples. For example, for a spanner with type CHAR(10), 10 bytes would be seen. And if we save a row of less than 10 characters in the column, then it will be supplemented with spaces.

    VARCHAR: Save a row. 1 byte is visible on the skin symbol. You can specify a specific length of the string - from 1 to 8,000 characters, for example, VARCHAR(10) . If a row is due to a mother of more than 8000 characters, then the MAX size is indicated, and up to 2 GB can be seen on the row selection: VARCHAR(MAX) .

    Not suitable for rich mov that take characters not encoded in Unicode.

    If a row of 5 characters is saved on a view of the CHAR type, as opposed to the VARCHAR(10) type, then the column itself will be saved with five characters.

    NCHAR : Takes a string from Unicode encoding from 1 to 4000 characters. On the skin, the symbol is seen 2 bytes. For example, NCHAR(15)

    NVARCHAR : Takes a row from the Unicode encoding. On the skin, the symbol is seen 2 bytes. You can set a specific size for 1 to 4,000 characters: . If a row is responsible for more than 4000 characters, then the MAX expansion is indicated, and up to 2 GB can be seen on a row.

Two more types TEXT and NTEXT are obsolete and it is not recommended to use them. Instead of them, VARCHAR and NVARCHAR can be replaced.

Apply the designation of row columns:

Email VARCHAR(30), Comment NVARCHAR(MAX)

Binary types of data

    BINARY: Takes binary data from a lookalike sequence of 1 to 8000 bytes.

    VARBINARY : Takes binary data from a sequence of 1 to 8,000 bytes or up to 2^31-1 bytes with a variable MAX value (VARBINARY(MAX)).

Another binary type, the IMAGE type, is deprecated, and it is recommended to replace it with the VARBINARY type.

Other types of data

    UNIQUEIDENTIFIER : a unique GUID (actually a row of unique values), which takes up 16 bytes.

    TIMESTAMP : a decimal number, so it takes the version number of the table row. Takes 8 bytes.

    CURSOR: represents a set of rows.

    HIERARCHYID: represents a position in a hierarchy.

    SQL_VARIANT : You can save data to any T-SQL data type.

    XML: Takes XML documents or fragments of XML documents. Borrows up to 2 GB from memory.

    TABLE: represents a specific table.

    GEOGRAPHY : collects geographic data such as latitude and longitude.

    GEOMETRY: saves the coordinates of the location on the plane.

Tipi data SQL.

Description

String tipi

A row of symbols of fasting dozhina

CHAR (number of_characters)

A row of symbols of the change of life

VARCHAR (number of_characters)

The Great Row of Symbols of the Life of Life

Veliky Dviykovy

object of change

Numerical exact types

Whole number

Whole number. The number of orders is larger or more expensive INTEGER

Whole number. Number of ranks

less or more INTEGER

Number with a fixed coma

(number of marks - total number of signs, scale - signs after Komi)

(NUMERIC | DECIMAL | DEC) (number of rows, scale)

Numeric inaccurate types

Number with a floating coma

A number with a floating coma. Quantity of ranks more or more expensive REAL

DOUBLE PRECISION

Number with a floating coma

FLOAT (number of rows)

Timchasov tipi

The date. To avenge the river, that day is the moon

Timchasov score. To revenge the river, month, day, year, hvilin that second

TIMESTAMP (scale)

Hour. Revenge the year, hvilin that second (scale - kіlkіst

signs at the fractional part of seconds). It is possible to insert the timcha zone

TIME (scale)

Hourly interval.

Boolean type

Get logical values

      1. Literals

Literals are the simplest expressions, as they are the meanings of specific types. The skin type of data can be used to identify literals of their type. SQL has the following literals:

    symbolic rows (butt: "Symbol row"),

    double rows (butt: X"1AFFD561"),

    numbers (apply: 27 -863 0.173 .8582 -9572.5619 11.54E7 .94E194 93E-12 -29.629E27),

    time(DATE "2005-12-07" TIME "HH:MI:SS" TIMESTAMP "YYYY-MM-DD HH:MI:SS"),

    logical (TRUE, FALSE, UNKNOWN).

      1. Operators and virazi

Operators- move constructs that specify operations on data elements and turn the result of a new value. Elements of data, which are included in operators, are called operands and arguments. Operators are served by looking at special symbols and key words. For example, the multiplication operator is a zirochkoy (*), and the recheck operator on an unknown value is the IS NULL keyword.

There are two main types of operators. Unary can only have one operand and sound is given in this format:

operand operator

The binaries operate with two operands and look like this:

operand operator operand

In addition, there are special operators, yakі vykoristovuyut over two operands. The type of the operator is determined by the type of the matched arguments and the type of the result to be rotated. Є operators of these types:

    string(||);

    arithmetic;

    logical;

    predicate match;

    special predicates;

    operators over multiplies (tables).

Partition 3. Movie BasicsSQL

Lecture 19. Groups of operators. tipi danih

Language of relational databases SQL expansion in the middle of the 70s within the framework of the previous project of an experimental relational DBMS System R by IBM . Danish project including expansion of relational DBMS and movie SEQUEL (Structured English Query Language ). Tsya naming less often reflected the essence of the movie. Mova was oriented by the head rank on the manual and understandable formulary of the queries to the relational database, in fact, it was already the full scope of the relational database and the crimace of the operators, in the formulation of the queries and the manipulation of the database, so:

· designation of the database schema and manipulation;

· the designation of the exchange of numbers and triggers;

· creation of a database;

· designation of the structures of the physical level, yakі pіdtrimuyut effektivne vykonannya zapіv;

· automation of access to tables and fields;

· support point of saving transactions and vodkativ.

Like the 70s of the corporation Oracle letter of release of modifications variant of movie SEQUEL , which otrimav name SQL . In 1983 company IBM releases SQL from DB2 warehouse.

Mova SQL buv flooring in the distance, scho troch pіznіshe, in 1986 American National Standards Institute ( ANSI ) Having adopted yoga as a standard. Since then, the standard has already looked at each other a few times, in 1989, 1992. as a result of the movie SQL some minor changes were made. In Denmark, the most widened standard is є SQL-92.

Tipi teamsSQL

Command Move SQL , mentally, you can divide it into groups:

· DCL ( Data control language) - Mova management danimi. The move command is recognized as an access to information that is stored in the database. (Table 19.1);

· DDL (Data Definition Language) - Mova vznachennya danikh. Several commands are selected to create and change the structure of database objects (Table 19.2);

· DML ( Data Manipulation language) - Mova manipulation of danim. Whiskers are used to manipulate information that is stored in database objects (Table 19.3);

· DQL ( Data Query language) - Mova zapitіv until danih. The most frequent victorious group, which consists of just one operator SELECT , recognized for the formation of zapitіv to DB (table 19.4);

· TCL (transaction control language) - mova transaction management (table 19.5);

CCL (Cursor Control Language ) - mov cursor control (table 19.6);

Language SQL is non-procedural, but not less, in the middle of SQL Server a number of different key constructs have been transferred, without any impossible written efficient algorithms, for example, operator arcs, wash cycles too.

Table 19.1 - Costs of managing danimi DCL

Operator

Description

ALTER DATABASE

Changing a set of basic database objects

ALTER DBAREA

Changes in the main area of ​​database saving

ALTER PASSWORD

Change the password for all data bases

CREATE DATABASE

I create a new database and define the main parameters

CREATE DBAREA

I create the area of ​​​​saving and robbing її accessible for the placement of data

DROP DATABASE

Viewing the database (for the presence of rights)

DROP DBAREA

You can see the saving area, as it does not host active data

GRANT

Granting access rights to diviz DB objects

REVOKE

Allows access rights to database objects or over actions with database objects

Table 19.2 - Data assignment operators DDL

Operator

Description

CREATE TABLE

Create a new table in the database

DROP TABLE

View the basic table from the database

ALTER TABLE

Change the structure of the tables or the table layout

CREATE VIEW

I create a statement (virtual table) in accordance with the action SQL query

DROP VIEW

You see before the creation of the manifestation

ALTER VIEW

Change the actual notice

CREATE INDEX

Create an index for a single table

DROP INDEX

View the key index

Table 19.3 - Data Manipulation Operators DML

Operator

Description

DELETE

You see one or a few records, it is clear to the minds of the mind. The statement of the operator is consistent with the principles of consistency support, so the operator does not need to be correct, it must be syntactically written correctly

INSERT

Insert one or more records, zgidno from the mind selection, to the base table

UPDATE

Update the value of one or more fields in one or more records, which is suitable for the minds of the selection

Table 19.4 - Mova zapitіv before data DQL

Operator

Description

SELECT

The operator, which is more realizing the possibility of relational algebra. Allows you to formulate the resultant suggestion that supports the request

Table 19.5 - Transaction Management Fees TCL

Operator

Description

COMMIT

I complete the transaction (complex mutual processing of information, combined with the transaction)

ROLLBACK

Transaction log (recording the changes made during the course of the transaction)

SAVEPOINT

Selecting an intermediate point (stand) of the DB for the implementation of the possibility of retrieval

Table 19.6 - Cursor controls CL

Operator

Description

DECLARE

Displays the cursor for the

OPEN

Display Cursor

FETCH

Reading a row of rows from the virtual ND shown to the cursor

CLOSE

Close cursor

PREPARE

Prepare the SQL statement for dynamic execution

EXECUTE

Override SQL statement, before preparation before dynamic override

tipi danih movi SQL

Mov SQL has six scalar data types defined by the standard. Їx short description given in table 19.7

Table 19.7 - tipi danih movi SQL

data type

goloshennia

Symbolic

CHAR | VARCHAR

Bitovy

bit | BIT VARYING

Exact numbers

NUMERIC | DECIMAL | INTEGER | SMALLINT

Speech numbers

FLOAT | REAL | DOUBLE PRECISION

date hour

DATE | time | TIMESTAMP

interval

INTERVAL

String types:

§ CHARACTER(n) or CHAR(n) - character strings of the current date n symbols. When you set the type of skin value, you must enter n symbols, and as a real value borrow less, lower n symbols, the DBMS automatically adds spaces to the daily symbols.

§ VARCHAR(n) - rows of symbols of the change of life.

Bit types:

§ In IT (p) - a row of battles of the post-mortem day.

§ BIT VARYING(n) - a row of battles of change.

Exact types:

§ NUMERIC[(n,m)] - exact numbers, here і - total number of digits in number. le, m - the number of digits in the decimal point.

§ DECIMAL[(n,m)] - exact numbers, here n - the total number of digits in the number, m - the number of digits left hand in the decimal point.

§ DEC[(n,m)] - same as DECIMAl.[(n,m)].

§ INTEGER or INT - integer numbers.

§ SMALLINT - the number of the smaller range.

Speech types:

§ FLOAT [(n)] - numbers of high precision, which are taken from the floating point form. Here n - The number of bytes to reserve for saving one number. The range of numbers is implementation specific.

§ REAL - speech type of numbers, similar to numbers with floating point, lower precision, lower FLOAT.

§ DOUBLE PRECISION data type specification with higher implementation precision, lower implementation precision for REAL.

Type date/hour and interval:

§ DATE - calendar date.

§ TIME - hour format.

§ T I ME S TAMR (accuracy) - date and hour.

§ INTERVAL - time interval.

The majority of commercial DBMSs support additional types of data that are specific to the standard. So, for example, in practice, all DBMSs, in another way, support the type of data to represent the unstructured text of the great obligation. This type is similar to the MEMO type in the desktop DBMS. These types are named differently, for example, ORACLE calls this type LONG, DB2 - LONG VARCHAR, SYBASE and MS SQL Server - TEXT.

Control nutrition

1. What is language SQL?

2. What is my sleeping partner SQL that relational algebra?

3. Yaki zasobi include mova SQL?

4. What types of commands are seen in the movie SQL?

5. DML.

6. Name the main movie commands DDL.

7. Name the main movie commands DCL.

8. Name the main movie commands DQL.

9. Name the main commands of the move transaction transactions.

10. Name the main types of these movies SQL.

11. Name row types of data movies SQL.

12. Name the number types of data of the movie SQL.

13. Name tipi tribute to give that hour.

Today, the world has a great number of technologies and tools that are used to collect information. Basis of data is one of the most wide-ranging benefits. p align="justify"> For work with them, different control systems are awarded. Such a way of saving transmission is that all information is clearly structured and entered into special tables. Tables, in their own way, are composed of stovptsiv-attributes of the same type of information.

What is the type of data?

Today, there is an occasional sprat, which explains the essence of the concept of “type of data”. The skin of them can be one big zmist. Mentally, the type of data can be recognized as a group of data, which are characterized by її values ​​- numerical, symbolic only - as well as operations, which can zastosovuvatysya according to the value to these values. The scope of the selection of different types of data is even richer. Data can be twisted not only for the purpose of collecting information, but also when programming for completing assignments. With the development of programs of great expansion, the practice of choosing the best types of data from the first set of operations began. The basis of the information of the koristuvach is to lie the main types of data. The SQL standard for foundations based on the widest types of information, but with the most important additions.

Tipi data: classification

The grouping of data for the type appeared long ago. Vaughn bula viklikana necessary structurization of all communication of information to ensure the integrity of their processing. Today, in the basis of all basic types of data, there are two basic ones: symbolic and numerical. On the basis of these data, the current classification was broken up, as it includes quotations, numbers, logical, numerals with a floating coma and a row type of information. All vishchezgadane povnіstyu ohoplyuє klasifіkatsіyu SQL. Proteza for modern data base management systems develop special overhead systems. Before them, MySQL and Oracle are seen.

Basic types of data

Types of data, which are used when creating table attributes that comply with SQL language standards, can be divided into 4 classes: string values, fractions, integer values, hour and date values.

Row type danich

The first type of data allows you to save whether or not the information given by looking at the symbols. In this way, there are special symbols and letters, which in totality will be combined with SQL, like a row. Below is a type of data, yakі approve the first group:

- CHAR (size) - this type is selected for rows saving. Indications at the arms, the parameter allows you to fix the length of the row, which is saved. For a row, you can set the maximum size in bytes - 255.

- VAR CHAR (size) - by analogy to the forward type, this type allows you to save rows, the length of which does not exceed 255 characters. The main value of this type of CHAR type lies in the fact that for the purpose of saving the value of this type, the necessary amount of memory is seen. In this way, for a row that consists of 5 characters, 6 bytes of memory are needed. For the first time, the memory for saving the value will be seen correctly up to the designated parameter.

- TINY TEXT - this type is reserved for collecting text information, which does not exceed 65,535 characters.

- BLOB - this type is similar to the TEXT type. Vin allows you to store text information in the database, which can be up to 65535 characters. However, in practice, this type can be used for saving little ones, sound information, electronic documents, and so on.

— MEDIUM TEXT – this type is broken down based on the TEXT type. For the amount of money increased to 16 777 215 symbols for the amount of money, the type allows you to save more money.

- MEDIU MBLOB - zastosovuetsya for sberіgannya e-documentіnі, rozmiru іn't move 16777215 characters.

- LONG TEXT - for functionality similar to the previous types of data, however, it may require memory, up to 4 GB.

- LONG BLOB - gives the possibility to place in the database the data of the great obligation - 4294967295 symbols.

ENUM is a special type of data that is selected for setting a list of different values. The target type allows you to enter 65535 values. Rows of this type can be filled with only one of the values, assigned to a plurality. For example, if the value added to the given list is added, the empty value will be written to the table.

- SET - this type of data defines anonymous valid values. On the front view of the front type, wins for a total of 64 parameters, so that you can pronounce the deck with the elements of the given arguments.

Table with other types of data

The fractional SQL data type is reserved for storing numbers from floating point. As a rule, in practice, data of this type characterize various financial indicators. Depending on the required accuracy, one of the number of representations of the following types can be scored.

FLOAT (sized) - zastosovuetsya to save fractional numbers assigned precision - d;

- DOUBLE (sized) – zastosovuetsya for saving shots from double accuracy;

DECIMAL (size, d) – zastosovuetsya to save shotgun values ​​from looking rows. Zastosovuєtsya in bank accounts, the accuracy of the shot part can reach 8 or 10 characters.

It is impossible to know the two first types in this galusi. The saving of financial indications in the form of rows can significantly facilitate the accomplishment of the riches of practical tasks. When carrying out operations and changes in financial nutrition, SQL-transformation of data types can be of great importance. The data collectors should ensure the type of information storage and processing methods, so that the data were permanently left unchanged.

Data of the cylinder type

Okremy group of numbers, which makes one of the main classes, є tsіlі numbers. Integer types are based on the base type INTEGER with various extensions of powers.

  • INT (size) - wins for saving as many data in the range [-231; 231-1].
  • TINYINT (size) – wicked to collect numbers in the range of -128 to 127.
  • SMALLINT (size) - characterized by a slightly larger data range, which are taken from -32768 to 32767.
  • MEDIUMINT (size) – variant for saving numbers of sizes from -223 to 223-1.
  • BIGINT (size) – range of integer values ​​from -263 to 263-1.

By choosing the correct data type, you can save some memory and change the server time to wait for the required SQL queries. Types of data of that їх range determine the amount of memory for saving. The retailers need to remember that the choice of great ranges for attributes can cause an increase in memory costs. Following a clear analysis of the rozv'yazuvani zavdannya and revealing the situation, in some cases a clear range of data is assigned to the mind's choice of numbers with a sign. Since there is a small range of arguments to win, and all numbers will be positive, then it would be more correct to match with an unsigned type, for which the attribute is UNSIGNED.

Tipi give the hour that date

Types of times and dates are of great interest to the fundamentals of SQL. The selection of lower types can give additional advantages in the development of systems, the work of which can be found without interruption in the form of hourly indications.

  • DATE - the main type used to select the date in the "Rik-Month-Day" format. Values ​​are subdivided through "-". However, sometimes, like a retailer, they can be zadіyanі, be it symbols, behind a bunch of numbers.
  • TIME - allows you to enter the hour value in the table box. Values ​​are given in hh:mm:ss format.
  • DATE TIME - this type is the same for its functions of the two previous ones. The format for collecting data from someone else looks like this: "yyyy-mm-dd: hh: mm: ss".
  • TIME STAMP – this type saves the date of the hour, which counts the number of seconds that have elapsed since January 01, 1970 before the specified value.
  • YEAR (M) – zastosovuetsya for sberіgannya rіchnyh znacheny dvuh- or kotyrіznachnoj format.

What else do you need to know? All presentations and types of data have been systematized by Microsoft. This report also developed a type of data SQL. So, for example, it was painted with the shape of the bulo, which obsyag memory is seen under the hour of victorious skin type of data. After understanding all the available information, it is easier for retailers to design the structure of the base table depending on the hardware capabilities of the server.

NULL - special indicator

In certain cases, the hour of filling in the data bases is the situation, if, when adding to the table entry, it is necessary to enter information from all the entries. For which it is necessary to select a special indicator of empty recognition or NULL. Vin yak dopomіzhny zasіb zastosovuє mov SQL. Tipi data stovptsіv, yakі neobov'yazkovo zapovnyuvatisya zapovnyuvatisya, zakazuyutsya s operator, scho allows you to add empty values ​​when collating the table. Also, the NULL operator with a variable sub-prefix NOT can be a variable to match the language of all values. Specifier NULL is not allowed for the type. Vin is simply entered in database tables with empty values. Therefore, as a whole, you can combine combinations with one of the representations of more types of data.

© 2022 androidas.ru - All about Android