{"id":407040,"date":"2024-06-29T19:18:40","date_gmt":"2024-06-29T19:18:40","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=407040"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=407040","title":{"rendered":"<span>\u041a\u0430\u0440\u043c\u0430\u043d\u043d\u044b\u0439 \u0441\u043f\u0440\u0430\u0432\u043e\u0447\u043d\u0438\u043a: \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0430 MS SQL Server \u0438 PostgreSQL<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/0f0\/2a3\/7da\/0f02a37dae365462dbb191b1c6b91bcf.jpg\" alt=\"\" title=\"\" width=\"1920\" height=\"1081\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/0f0\/2a3\/7da\/0f02a37dae365462dbb191b1c6b91bcf.jpg\" data-blurred=\"true\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e, \u0443\u0432\u0430\u0436\u0430\u0435\u043c\u044b\u0435 \u0445\u0430\u0431\u0440\u0430\u0436\u0438\u0442\u0435\u043b\u0438!<\/p>\n<p>\u042f \u0437\u0430\u043d\u0438\u043c\u0430\u044e\u0441\u044c \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u043e\u043c \u043a\u043e\u0434\u0430 \u0438\u0437 MS SQL Server \u0432 PostgreSQL \u0441 \u043d\u0430\u0447\u0430\u043b\u0430 2019 \u0433\u043e\u0434\u0430 \u0438 \u0441\u0435\u0433\u043e\u0434\u043d\u044f\u00a0 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0443 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u044d\u0442\u0438\u0445 \u0421\u0423\u0411\u0414.<\/p>\n<p>\u0412 <a href=\"https:\/\/habr.com\/ru\/post\/457602\/\"><u>\u043f\u0440\u043e\u0448\u043b\u043e\u0439 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438<\/u><\/a> \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u043b\u0438 \u043e\u0442\u043b\u0438\u0447\u0438\u044f \u0432 \u0431\u044b\u0441\u0442\u0440\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0438 MS SQL Server \u0438 PostgreSQL \u0434\u043b\u044f \u00ab1C\u00bb.<\/p>\n<p>\u0412 Ozon \u0435\u0441\u0442\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0438 \u043d\u0430 MS SQL Server, \u0438 \u043d\u0430 PostgreSQL: \u043f\u0435\u0440\u0432\u0430\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u043b\u043e\u0433\u0438\u0441\u0442\u0438\u043a\u0435 \u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0445 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0445 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432, \u0432\u0442\u043e\u0440\u0430\u044f \u2014 \u0432 mission critical-\u043f\u043e\u0434\u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0445, \u043e\u0442 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u0431\u0438\u0437\u043d\u0435\u0441 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 (\u0441\u043a\u043b\u0430\u0434, \u043a\u043e\u0440\u0437\u0438\u043d\u0430, \u043e\u043f\u043b\u0430\u0442\u0430 \u043a\u0430\u0440\u0442\u0430\u043c\u0438, \u043f\u043b\u0430\u0442\u0435\u0436\u0438, \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u0442\u043e\u0432\u0430\u0440\u0430\u0445 \u043d\u0430 \u0441\u0430\u0439\u0442\u0435 \u0438 \u0434\u0440.).<\/p>\n<p>\u041f\u0435\u0440\u0438\u043e\u0434\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u043e\u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0437\u0430\u0434\u0430\u0447\u0438 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0430 \u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u0438\u0437 \u043e\u0433\u0440\u043e\u043c\u043d\u044b\u0445 \u043c\u043e\u043d\u043e\u043b\u0438\u0442\u043d\u044b\u0445 \u0431\u0430\u0437 \u0438\u0437 MS SQL Server \u0432 PostgreSQL. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u0440\u0430\u0432\u043d\u0438\u043c \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0430 \u044d\u0442\u0438\u0445 \u0421\u0423\u0411\u0414 \u0434\u043b\u044f \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0433\u043e \u0447\u0442\u0435\u043d\u0438\u044f \u043a\u043e\u0434\u0430, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0431\u044b\u0441\u0442\u0440\u043e \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u043a\u043e\u0434 \u0438\u0437 MS SQL Server \u0434\u043b\u044f PostgreSQL \u0438 \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442.<\/p>\n<p>\u041d\u0430\u0447\u043d\u0451\u043c \u0441 \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0442\u0438\u043f\u043e\u0432.<\/p>\n<h2>\u0421\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0442\u0438\u043f\u043e\u0432<\/h2>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/c95\/c76\/4f2\/c95c764f2040abfd43faff4681be6350.jpg\" alt=\"\" title=\"\" width=\"1920\" height=\"1081\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/c95\/c76\/4f2\/c95c764f2040abfd43faff4681be6350.jpg\" data-blurred=\"true\"\/><figcaption><\/figcaption><\/figure>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p>MS SQL<\/p>\n<\/td>\n<td>\n<p>PostgreSQL<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>BIGINT<\/p>\n<\/td>\n<td>\n<p>BIGINT, INT8<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>BINARY(n)<\/p>\n<\/td>\n<td>\n<p>BYTEA<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>VARBINARY(n)<\/p>\n<\/td>\n<td>\n<p>BYTEA<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>VARBINARY(max)<\/p>\n<\/td>\n<td>\n<p>BYTEA<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>ROWVERSION<\/p>\n<\/td>\n<td>\n<p>BYTEA<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>IMAGE<\/p>\n<\/td>\n<td>\n<p>BYTEA<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>FIELDHIERARCHYID<\/p>\n<\/td>\n<td>\n<p>BYTEA, LTREE (<a href=\"https:\/\/www.postgresql.org\/docs\/11\/ltree.html\"><u>\u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435<\/u><\/a>)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>BIT<\/p>\n<\/td>\n<td>\n<p>BOOLEAN, BOOL<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>CHAR(n), n&lt;=8000<\/p>\n<\/td>\n<td>\n<p>TEXT<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>NCHAR(n), n&lt;=4000<\/p>\n<\/td>\n<td>\n<p>TEXT<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>VARCHAR(n), n&lt;=8000<\/p>\n<\/td>\n<td>\n<p>TEXT<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>NVARCHAR(n), n&lt;=4000<\/p>\n<\/td>\n<td>\n<p>TEXT<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>VARCHAR(max)<\/p>\n<\/td>\n<td>\n<p>TEXT<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>NVARCHAR(max)<\/p>\n<\/td>\n<td>\n<p>TEXT<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>TEXT<\/p>\n<\/td>\n<td>\n<p>TEXT<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>NTEXT<\/p>\n<\/td>\n<td>\n<p>TEXT<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>FLOAT(n)<\/p>\n<\/td>\n<td>\n<p>DOUBLE PRECISION, FLOAT8<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>SMALLMONEY<\/p>\n<\/td>\n<td>\n<p>MONEY<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>MONEY<\/p>\n<\/td>\n<td>\n<p>MONEY<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>INT, INTEGER<\/p>\n<\/td>\n<td>\n<p>INT, INTEGER, INT4<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>SMALLINT<\/p>\n<\/td>\n<td>\n<p>SMALLINT, INT2<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>NUMERIC(n,m)<\/p>\n<\/td>\n<td>\n<p>NUMERIC(n,m)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>DEC(n,m), DECIMAL(n,m)<\/p>\n<\/td>\n<td>\n<p>DEC(n,m), DECIMAL(n,m)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>TINYINT<\/p>\n<\/td>\n<td>\n<p>SMALLINT, INT2<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>REAL<\/p>\n<\/td>\n<td>\n<p>REAL, FLOAT4<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>UNIQUEIDENTIFIER<\/p>\n<\/td>\n<td>\n<p>CHAR(16), UUID<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>DATE<\/p>\n<\/td>\n<td>\n<p>DATE<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>TIME(n)<\/p>\n<\/td>\n<td>\n<p>TIME(n)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>DATETIME<\/p>\n<\/td>\n<td>\n<p>TIMESTAMP(3)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>DATETIME2(n)<\/p>\n<\/td>\n<td>\n<p>TIMESTAMP(m)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>DATETIMEOFFSET(n)<\/p>\n<\/td>\n<td>\n<p>TIMESTAMP(n) WITH TIME ZONE, TIMESTAMPTZ<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>SMALLDATETIME<\/p>\n<\/td>\n<td>\n<p>TIMESTAMP(0)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>XML<\/p>\n<\/td>\n<td>\n<p>XML<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p><em>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435.<\/em> \u0422\u0438\u043f\u044b CHAR \u0438 VARCHAR \u043b\u0443\u0447\u0448\u0435 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c. \u041f\u0440\u0438\u0447\u0438\u043d\u044b \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u044b <a href=\"https:\/\/wiki.postgresql.org\/wiki\/Don%27t_Do_This\"><u>\u0437\u0434\u0435\u0441\u044c<\/u><\/a>.<\/p>\n<p>\u0411\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043e \u0442\u0438\u043f\u0430\u0445 \u0434\u0430\u043d\u043d\u044b\u0445:<\/p>\n<ol>\n<li>\n<p><a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/t-sql\/data-types\/data-types-transact-sql?view=sql-server-ver15\"><u>MS SQL Server<\/u><\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/postgrespro.ru\/docs\/postgresql\/12\/datatype\"><u>PostgreSQL<\/u><\/a><\/p>\n<\/li>\n<\/ol>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0435\u0440\u0435\u0439\u0434\u0451\u043c \u043a \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044e \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0430 MS SQL Server \u0438 PostgreSQL.<\/p>\n<h2>\u0421\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0430 MS SQL Server \u0438 PostgreSQL<\/h2>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/720\/ada\/ab6\/720adaab69811b26cf288f482f308f62.jpg\" width=\"1921\" height=\"1081\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/720\/ada\/ab6\/720adaab69811b26cf288f482f308f62.jpg\" data-blurred=\"true\"\/><figcaption><\/figcaption><\/figure>\n<p><strong>I. \u0420\u0435\u0433\u0438\u0441\u0442\u0440\u043e\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0435 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u043a \u0441\u0445\u0435\u043c\u0430\u043c, \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u043c (\u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f\u043c) \u0438 \u0438\u0445 \u043f\u043e\u043b\u044f\u043c \u0438 \u0434\u0440\u0443\u0433\u0438\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445<\/strong><\/p>\n<p>\u0412 MS SQL Server \u043f\u0440\u0438 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f\u0445 \u043a \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043d\u044b\u0435 \u0441\u043a\u043e\u0431\u043a\u0438 (\u043e\u043d\u0438 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b, \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0441\u043b\u0438 \u0432 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0438\u043b\u0438 \u0435\u0433\u043e \u043f\u043e\u043b\u044f \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u043d\u0435\u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u044b\u0435 \u0441\u0438\u043c\u0432\u043e\u043b\u044b):<\/p>\n<pre><code class=\"sql\">[schema] [table] [view] [object] [table].[field] [view].[field] [schema].[table] [schema].[view] [schema].[object] [schema].[table].[field] [schema].[view].[field]<\/code><\/pre>\n<p>\u0412 PostgreSQL \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0434\u0432\u043e\u0439\u043d\u044b\u0435 \u043a\u0430\u0432\u044b\u0447\u043a\u0438 (\u043e\u043d\u0438 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b, \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0441\u043b\u0438 \u0432 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u0437\u0430\u0433\u043b\u0430\u0432\u043d\u044b\u0435 \u0431\u0443\u043a\u0432\u044b \u0438\u043b\u0438 \u0435\u0441\u0442\u044c \u043d\u0435\u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u044b\u0435 \u0441\u0438\u043c\u0432\u043e\u043b\u044b \u0432 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0438\u043b\u0438 \u0435\u0433\u043e \u043f\u043e\u043b\u044f):<\/p>\n<pre><code class=\"sql\">\"schema\" \"table\" \"view\" \"table\".\"field\" \"view\".\"field\" \"schema\".\"table\" \"schema\".\"view\" \"schema\".\"table\".\"field\" \"schema\".\"view\".\"field\"<\/code><\/pre>\n<p><strong>II. \u0412\u044b\u0431\u043e\u0440\u043a\u0430 \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0445 N \u0434\u0430\u043d\u043d\u044b\u0445<\/strong><\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p>\u0412 MS SQL Server \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f <a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/t-sql\/queries\/top-transact-sql?view=sql-server-ver15\">TOP<\/a>:<\/p>\n<\/td>\n<td>\n<p>\u0412 PostgreSQL \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f <a href=\"https:\/\/postgrespro.ru\/docs\/postgresql\/14\/queries-limit\">LIMIT<\/a>:<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>SELECT TOP(N) &#8230;;<\/p>\n<\/td>\n<td>\n<p>SELECT &#8230;. LIMIT N;<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p><strong>III. \u041f\u043e\u0441\u0442\u0440\u0430\u043d\u0438\u0447\u043d\u0430\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 (\u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0435\u0435 \u043e\u043a\u043d\u043e)<\/strong><br \/>\u0417\u0430\u0434\u0430\u0447\u0430: \u0438\u0437\u0432\u043b\u0435\u0447\u044c 100 \u0441\u0442\u0440\u043e\u043a \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 202-\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u043e \u0432\u043e\u0437\u0440\u0430\u0441\u0442\u0430\u043d\u0438\u044e \u0434\u0430\u0442\u044b \u0440\u043e\u0436\u0434\u0435\u043d\u0438\u044f:<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td data-colwidth=\"334\" width=\"334\">\n<p>\u0432 <a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/t-sql\/queries\/select-order-by-clause-transact-sql?view=sql-server-ver15\">MS SQL Server<\/a>:<\/p>\n<\/td>\n<td>\n<p>\u0432 <a href=\"https:\/\/postgrespro.ru\/docs\/postgresql\/14\/sql-select\">PostgreSQL<\/a>:<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"334\" width=\"334\">\n<p>SELECT *<br \/>FROM tbl<br \/>ORDER BY BirthDate ASC<br \/>OFFSET 201 ROW FETCH<br \/>NEXT 100 ROWS ONLY;<\/p>\n<\/td>\n<td>\n<p>select *<br \/> from tbl<br \/> order by BirthDate asc<br \/> [&#8212;offset 201 row fetch<br \/> next 100 rows only;]<br \/> LIMIT 100 OFFSET 200<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td colspan=\"2\" data-colwidth=\"334,0\" width=\"334\">\n<p><em>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435.<\/em> \u0412\u043c\u0435\u0441\u0442\u043e row \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c rows \u0432 \u043b\u044e\u0431\u043e\u043c \u043c\u0435\u0441\u0442\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u0430 \u0432\u043c\u0435\u0441\u0442\u043e next \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c first \u0432 \u043e\u0431\u0435\u0438\u0445 \u0421\u0423\u0411\u0414.<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p><strong>IV. \u0412\u044b\u0431\u043e\u0440\u043a\u0430 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u043d\u0435\u043f\u0443\u0441\u0442\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f<\/strong><\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p>MS SQL Server<\/p>\n<\/td>\n<td>\n<p>PostgreSQL<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/t-sql\/language-elements\/coalesce-transact-sql?view=sql-server-ver15\"><u>COALESCE<\/u><\/a> \u2014 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u0442\u0441\u044f<\/p>\n<p><a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/t-sql\/functions\/isnull-transact-sql?view=sql-server-ver15\"><u>ISNULL<\/u><\/a> \u2014 \u043d\u0435 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u0442\u0441\u044f<\/p>\n<\/td>\n<td>\n<p><a href=\"https:\/\/postgrespro.ru\/docs\/postgresql\/14\/functions-conditional#FUNCTIONS-COALESCE-NVL-IFNULL\"><u>coalesce<\/u><\/a><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p><strong>V. \u0422\u0435\u0440\u043d\u0430\u0440\u043d\u044b\u0439 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 IIF<\/strong><\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td data-colwidth=\"337\" width=\"337\">\n<p>MS SQL Server<\/p>\n<\/td>\n<td>\n<p>PostgreSQL<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"337\" width=\"337\">\n<p><a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/t-sql\/functions\/logical-functions-iif-transact-sql?view=sql-server-ver15\"><u>IIF<\/u><\/a> (&lt;\u0443\u0441\u043b\u043e\u0432\u0438\u0435>,&lt;\u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435_\u0435\u0441\u043b\u0438_\u0443\u0441\u043b\u043e\u0432\u0438\u0435_\u0438\u0441\u0442\u0438\u043d\u043d\u043e>,&lt;\u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435_\u0435\u0441\u043b\u0438_\u0443\u0441\u043b\u043e\u0432\u0438\u0435_\u043b\u043e\u0436\u043d\u043e>)<\/p>\n<p>\u0438\u043b\u0438<\/p>\n<p><a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/t-sql\/language-elements\/case-transact-sql?view=sql-server-ver15\"><u>CASE<\/u><\/a> WHEN &lt;\u0443\u0441\u043b\u043e\u0432\u0438\u0435> THEN &lt;\u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435_\u0435\u0441\u043b\u0438_\u0443\u0441\u043b\u043e\u0432\u0438\u0435_\u0438\u0441\u0442\u0438\u043d\u043d\u043e> ELSE &lt;\u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435_\u0435\u0441\u043b\u0438_\u0443\u0441\u043b\u043e\u0432\u0438\u0435_\u043b\u043e\u0436\u043d\u043e> END<\/p>\n<\/td>\n<td>\n<p><a href=\"https:\/\/postgrespro.ru\/docs\/postgresql\/14\/functions-conditional#FUNCTIONS-CASE\"><u>case<\/u><\/a> when &lt;\u0443\u0441\u043b\u043e\u0432\u0438\u0435> then &lt;\u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435_\u0435\u0441\u043b\u0438_\u0443\u0441\u043b\u043e\u0432\u0438\u0435_\u0438\u0441\u0442\u0438\u043d\u043d\u043e> else &lt;\u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435_\u0435\u0441\u043b\u0438_\u0443\u0441\u043b\u043e\u0432\u0438\u0435_\u043b\u043e\u0436\u043d\u043e> end<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p><strong>VI. \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u0441\u0435\u0432\u0434\u043e\u043d\u0438\u043c\u0430<\/strong><\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p>MS SQL Server<\/p>\n<\/td>\n<td>\n<p>PostgreSQL<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>AS \u2014 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u0442\u0441\u044f<\/p>\n<p>= \u2014 \u043d\u0435 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u0442\u0441\u044f<\/p>\n<\/td>\n<td>\n<p>as<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p><strong>VII. \u0412\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f CASE<\/strong><\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p>MS SQL Server<\/p>\n<\/td>\n<td>\n<p>PostgreSQL<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/t-sql\/language-elements\/case-transact-sql?view=sql-server-ver15\">CASE<\/a>-WHEN-THEN-END<\/p>\n<p><a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/t-sql\/language-elements\/case-transact-sql?view=sql-server-ver15\">CASE<\/a>-WHEN-THEN-ELSE-END<\/p>\n<\/td>\n<td>\n<p><a href=\"https:\/\/postgrespro.ru\/docs\/postgresql\/14\/functions-conditional#FUNCTIONS-CASE\">case<\/a>-when-then-end<\/p>\n<p><a href=\"https:\/\/postgrespro.ru\/docs\/postgresql\/14\/functions-conditional#FUNCTIONS-CASE\">case<\/a>-when-then-else-end<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p><strong>VIII. \u0420\u0430\u0431\u043e\u0442\u0430 \u0441 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c\u0438<\/strong><\/p>\n<p><strong>\u041e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439<\/strong><\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p>MS SQL Server<\/p>\n<\/td>\n<td>\n<p>PostgreSQL<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>DECLARE @val;<\/p>\n<\/td>\n<td>\n<p>declare val;<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td colspan=\"2\">\n<p><em>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435.<\/em> \u0412 MS SQL Server \u043f\u0440\u0438 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0437\u043d\u0430\u043a @ \u043f\u0435\u0440\u0435\u0434 \u0438\u043c\u0435\u043d\u0435\u043c, \u0430 \u0432 PostgreSQL \u2014 \u043d\u0435\u0442. \u0422\u0430\u043a\u0436\u0435, \u043f\u043e\u043c\u0438\u043c\u043e <a href=\"https:\/\/github.com\/postgres\/postgres\/tree\/c30f54ad732ca5c8762bb68bbe0f51de9137dd72\/src\/pl\/plpgsql\"><u>PL\/pgSQL<\/u><\/a>, \u0432 PostgreSQL \u043c\u043e\u0436\u043d\u043e \u0432\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u044f\u0437\u044b\u043a\u0438, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a <a href=\"https:\/\/github.com\/postgres\/postgres\/tree\/c30f54ad732ca5c8762bb68bbe0f51de9137dd72\/src\/pl\/plpython\"><u>PL\/Python<\/u><\/a> \u0438 <a href=\"https:\/\/github.com\/postgres\/postgres\/tree\/c30f54ad732ca5c8762bb68bbe0f51de9137dd72\/src\/pl\/plperl\"><u>PL\/Perl<\/u><\/a>.<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p><strong>\u041f\u0440\u0438\u0441\u0432\u043e\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f<\/strong><\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p>MS SQL Server<\/p>\n<\/td>\n<td>\n<p>PostgreSQL<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>SET @\u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f = \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435;<\/p>\n<\/td>\n<td>\n<p>\u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f := \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td colspan=\"2\">\n<p><em>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435.<\/em> \u0412 PostgreSQL \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f := \u0434\u043b\u044f <a href=\"https:\/\/github.com\/postgres\/postgres\/tree\/c30f54ad732ca5c8762bb68bbe0f51de9137dd72\/src\/pl\/plpgsql\"><u>PL\/pgSQL<\/u><\/a> \u0438 \u043f\u0440\u043e\u0441\u0442\u043e = \u0434\u043b\u044f <a href=\"https:\/\/github.com\/postgres\/postgres\/tree\/c30f54ad732ca5c8762bb68bbe0f51de9137dd72\/src\/pl\/plpython\"><u>PL\/Python<\/u><\/a> \u0438 <a href=\"https:\/\/github.com\/postgres\/postgres\/tree\/c30f54ad732ca5c8762bb68bbe0f51de9137dd72\/src\/pl\/plperl\"><u>PL\/Perl<\/u><\/a>.<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p><strong>\u0412\u044b\u0432\u043e\u0434 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043d\u0430 \u043a\u043e\u043d\u0441\u043e\u043b\u044c<\/strong><\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p>MS SQL Server<\/p>\n<\/td>\n<td>\n<p>PostgreSQL<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>print &#8216;\u0441\u0442\u0440\u043e\u043a\u0430&#8217;;<\/p>\n<p>print @\u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f;<\/p>\n<p>RAISERROR(@\u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f, 1, 1) WITH NOWAIT;<\/p>\n<\/td>\n<td>\n<p>RAISE NOTICE &#8216;%&#8217;, &#8216;\u0441\u0442\u0440\u043e\u043a\u0430&#8217;;<\/p>\n<p>RAISE NOTICE &#8216;%&#8217;, &lt;\u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f>;<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p><strong>IX. \u0423\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435\u043c \u043a\u043e\u0434\u0430<\/strong><\/p>\n<p><strong>\u0412\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0441\u043a\u0440\u0438\u043f\u0442\u0430<\/strong><\/p>\n<p>\u0412 MS SQL Server:<\/p>\n<pre><code class=\"sql\">declare @_query int; set @_query=777; set @query=1+8; RAISERROR(@_query, 1, 1) WITH NOWAIT; --PRINT @_query;<\/code><\/pre>\n<p>\u0412 PostgreSQL:<\/p>\n<p>\u0428\u0430\u0431\u043b\u043e\u043d:<\/p>\n<pre><code class=\"sql\">do $$ &lt;\u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445>  begin &lt;\u043a\u043e\u0434>  end; $$;<\/code><\/pre>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 (\u0432\u044b\u0432\u043e\u0434 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438):<\/p>\n<pre><code class=\"sql\">do $$ declare _query int; begin _query:=777; _query:=1+8; RAISE NOTICE '%', _query; end; $$;<\/code><\/pre>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 (\u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043a\u043b\u0438\u0435\u043d\u0442\u0443):<\/p>\n<pre><code class=\"sql\">do $$ declare _query int; begin _query:=777; _query:=1+8; PERFORM set_config('my._query', _query::text, FALSE); end; $$; SELECT current_setting ('my._query');<\/code><\/pre>\n<p>\u0414\u043b\u044f PostgreSQL:<\/p>\n<ol>\n<li>\n<p>\u0412 DBeaver (\u0431\u043e\u0431\u0440\u0435) \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u0436\u0430\u0442\u044c CTRL+SHIFT+O \u043f\u0440\u0438 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0438 \u043e\u043a\u043d\u0430 \u0432\u044b\u0432\u043e\u0434\u0430, \u0430 \u0432 pgAdmin \u0432\u044b\u0432\u043e\u0434 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438.<\/p>\n<\/li>\n<li>\n<p>\u0412 psql \u0438 \u0442\u0430\u043a \u0432\u0441\u0451 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442.<\/p>\n<\/li>\n<\/ol>\n<p><strong>\u0426\u0438\u043a\u043b WHILE<\/strong><\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p>MS SQL Server<\/p>\n<\/td>\n<td>\n<p>PostgreSQL<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>WHILE &lt;\u0443\u0441\u043b\u043e\u0432\u0438\u0435_\u043f\u0440\u0438_\u043a\u043e\u0442\u043e\u0440\u043e\u043c_\u0446\u0438\u043a\u043b_\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442><\/p>\n<p>BEGIN<\/p>\n<p>&#8230;<\/p>\n<p>END<\/p>\n<\/td>\n<td>\n<p>while &lt;\u0443\u0441\u043b\u043e\u0432\u0438\u0435_\u043f\u0440\u0438_\u043a\u043e\u0442\u043e\u0440\u043e\u043c_\u0446\u0438\u043a\u043b_\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442><\/p>\n<p>loop<\/p>\n<p>&#8230;<\/p>\n<p>end loop<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p><strong>\u041b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0432\u0435\u0442\u0432\u043b\u0435\u043d\u0438\u0435<\/strong><\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p>MS SQL Server<\/p>\n<\/td>\n<td>\n<p>PostgreSQL<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>IF-BEGIN-END<\/p>\n<p>IF-BEGIN-END-ELSE-BEGIN-END<\/p>\n<\/td>\n<td>\n<p>if-then-else-end if;<\/p>\n<p>if-then-elseif-then-else-end if;<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u0411\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043f\u0440\u043e \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435\u043c \u043a\u043e\u0434\u0430:<\/p>\n<ol>\n<li>\n<p><a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/t-sql\/language-elements\/control-of-flow?view=sql-server-ver15\"><u>\u0423\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435\u043c \u043a\u043e\u0434\u0430 \u0432 MS SQL Server<\/u><\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/postgrespro.ru\/docs\/postgresql\/14\/plpgsql-control-structures\"><u>\u0423\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0432 PostgreSQL<\/u><\/a><\/p>\n<\/li>\n<\/ol>\n<p><strong>X. \u0424\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u043e \u0441\u0442\u0440\u043e\u043a\u0430\u043c\u0438<\/strong><\/p>\n<p><strong>\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0434\u043b\u0438\u043d\u044b \u0441\u0442\u0440\u043e\u043a\u0438 (\u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u0432 \u0441\u0442\u0440\u043e\u043a\u0435)<\/strong><\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p>MS SQL Server<\/p>\n<\/td>\n<td>\n<p>PostgreSQL<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/t-sql\/functions\/len-transact-sql?view=sql-server-ver15\"><u>LEN<\/u><\/a> (&lt;\u0441\u0442\u0440\u043e\u043a\u0430>)<\/p>\n<\/td>\n<td>\n<p><a href=\"https:\/\/postgrespro.ru\/docs\/postgresql\/14\/functions-string\"><u>length<\/u><\/a> (&lt;\u0441\u0442\u0440\u043e\u043a\u0430>)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td colspan=\"2\">\n<p><em>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435.<\/em> \u0412 MS SQL Server \u0438\u0441\u043a\u043b\u044e\u0447\u0430\u044e\u0442\u0441\u044f \u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0435 \u043f\u0440\u043e\u0431\u0435\u043b\u044b. \u0415\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u0438 \u0438\u0445, \u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 <a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/t-sql\/functions\/datalength-transact-sql?view=sql-server-ver15\"><u>DATALENGTH<\/u><\/a> (&lt;\u0441\u0442\u0440\u043e\u043a\u0430>), \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u0443\u043c\u043c\u0430\u0440\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0431\u0430\u0439\u0442\u043e\u0432 \u0432 \u0441\u0438\u043c\u0432\u043e\u043b\u0430\u0445 \u0441\u0442\u0440\u043e\u043a\u0438.<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p><strong>\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u0441\u0438\u043c\u0432\u043e\u043b\u0430 \u043f\u043e \u0435\u0433\u043e \u043a\u043e\u0434\u0443:<\/strong><\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p>MS SQL Server<\/p>\n<\/td>\n<td>\n<p>PostgreSQL<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>char(n)<\/p>\n<\/td>\n<td>\n<p>chr(n)<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p><strong>\u041a\u043e\u043d\u043a\u0430\u0442\u0435\u043d\u0430\u0446\u0438\u044f \u0441\u0442\u0440\u043e\u043a<\/strong><\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p>MS SQL Server<\/p>\n<\/td>\n<td>\n<p>PostgreSQL<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>+<\/p>\n<\/td>\n<td>\n<p>||<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p><strong>\u041d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u0432\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u043f\u043e\u0434\u0441\u0442\u0440\u043e\u043a\u0438<\/strong><\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p>\u0412 MS SQL Server:<\/p>\n<\/td>\n<td>\n<p>\u0412 PostgreSQL:<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>CHARINDEX(&lt;\u0447\u0442\u043e_\u0438\u0449\u0435\u043c>, &lt;\u0433\u0434\u0435_\u0438\u0449\u0435\u043c>,&lt;\u0441_\u043a\u0430\u043a\u043e\u0439_\u043f\u043e\u0437\u0438\u0446\u0438\u0438_\u0438\u0449\u0435\u043c_\u043d\u0430\u0447\u0438\u043d\u0430\u044f_\u0441_1>)<\/p>\n<\/td>\n<td>\n<p>strpos(&lt;\u0433\u0434\u0435_\u0438\u0449\u0435\u043c>, &lt;\u0447\u0442\u043e_\u0438\u0449\u0435\u043c>)<\/p>\n<p>strpos(substring(&lt;\u0433\u0434\u0435_\u0438\u0449\u0435\u043c>, &lt;\u0441_\u043a\u0430\u043a\u043e\u0439_\u043f\u043e\u0437\u0438\u0446\u0438\u0438_\u0438\u0449\u0435\u043c_\u043d\u0430\u0447\u0438\u043d\u0430\u044f_\u0441_1>, length(&lt;\u0433\u0434\u0435_\u0438\u0449\u0435\u043c>)- &lt;\u0441_\u043a\u0430\u043a\u043e\u0439_\u043f\u043e\u0437\u0438\u0446\u0438\u0438_\u0438\u0449\u0435\u043c_\u043d\u0430\u0447\u0438\u043d\u0430\u044f_\u0441_1>+1), &lt;\u0447\u0442\u043e_\u0438\u0449\u0435\u043c>)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td colspan=\"2\">\n<p><em>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435.<\/em> \u0422\u043e\u0447\u043d\u043e\u0433\u043e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u044f \u043d\u0435 \u0431\u0443\u0434\u0435\u0442, \u0435\u0441\u043b\u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u044c \u043f\u043e\u0438\u0441\u043a \u043d\u0435 \u0441 \u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u0442\u0440\u043e\u043a\u0438.<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p><strong>\u0420\u0435\u0433\u0438\u0441\u0442\u0440\u043e\u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0435 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0438 \u043f\u043e\u0438\u0441\u043a \u0434\u0430\u043d\u043d\u044b\u0445<\/strong><\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td data-colwidth=\"206\" width=\"206\">\n<p>\u0412 MS SQL Server:<\/p>\n<\/td>\n<td>\n<p>\u0412 PostgreSQL:<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"206\" width=\"206\">\n<p>1. LIKE<\/p>\n<p>2. a = b<\/p>\n<p>3. &lt;><\/p>\n<p>4. a in (b1, &#8230;)<\/p>\n<\/td>\n<td>\n<p>1. ilike<\/p>\n<p>2. lower(a) = lower(b) \u0438\u043b\u0438 upper(a)=upper(b)<\/p>\n<p>3. lower(a) &lt;> lower(b) \u0438\u043b\u0438 upper(a)&lt;>upper(b)<\/p>\n<p>4. lower(a) in (lower(b1), &#8230;) \u0438\u043b\u0438 upper(a) in (upper(b1), &#8230;)<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p><em>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435.<\/em> \u0412 PostgreSQL \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0441\u0442\u0438 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044e \u0447\u0435\u0440\u0435\u0437 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430:<\/p>\n<pre><code class=\"sql\">create [concurrently] index idx_lower_&lt;field>  on &lt;schema>.&lt;table> (lower(&lt;field>));  --\u041f\u043e\u0441\u043b\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f concurrently-\u0438\u043d\u0434\u0435\u043a\u0441\u0430,  --\u0435\u0433\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u043d\u0430 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0431\u0438\u0442\u044b\u0445 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c: SELECT indexrelid::regclass FROM pg_index where not indisvalid;  --\u0414\u0430\u043b\u0435\u0435 \u0434\u043b\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0438 \u043f\u043e \u043d\u0443\u0436\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435  --\u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 ANALYZE: ANALYZE &lt;table>;<\/code><\/pre>\n<p>\u0411\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043f\u0440\u043e \u043a\u043e\u043c\u0430\u043d\u0434\u0443 <a href=\"https:\/\/postgrespro.ru\/docs\/postgresql\/14\/sql-analyze\"><u>ANALYZE<\/u><\/a>.<\/p>\n<p><strong>\u0421\u043b\u0438\u044f\u043d\u0438\u0435 \u0441\u0442\u0440\u043e\u043a \u043f\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0443 \u0432 \u043e\u0434\u043d\u0443 \u0441\u0442\u0440\u043e\u043a\u0443 \u043f\u043e \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u043c\u0443 \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044e<\/strong><\/p>\n<p>\u0412 MS SQL Server \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/t-sql\/functions\/stuff-transact-sql?view=sql-server-ver15\"><u>STUFF<\/u><\/a> \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"sql\">STUFF(( SELECT DISTINCT                  ', ' + CONVERT(varchar, tbl.&lt;\u043f\u043e\u043b\u0435>)           FROM             &lt;\u0441\u0445\u0435\u043c\u0430>.&lt;\u0442\u0430\u0431\u043b\u0438\u0446\u0430> tbl           [WHERE             &lt;\u0443\u0441\u043b\u043e\u0432\u0438\u044f>]           FOR XML PATH(''))       , 1       , 1       , '') AS STUFF_tbl;<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0436\u0435 \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 \u0432\u0435\u0440\u0441\u0438\u0438 2017 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f <a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/t-sql\/functions\/string-agg-transact-sql?view=sql-server-ver15\"><u>STRING_AGG<\/u><\/a>.<\/p>\n<p>\u0412 PostgreSQL \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <a href=\"https:\/\/www.postgresqltutorial.com\/postgresql-aggregate-functions\/postgresql-string_agg-function\/\"><u>string_agg<\/u><\/a> \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"sql\">string_agg((SELECT distinct ', ' || cast(tbl.&lt;\u043f\u043e\u043b\u0435> as VARCHAR) FROM &lt;\u0441\u0445\u0435\u043c\u0430>.&lt;\u0442\u0430\u0431\u043b\u0438\u0446\u0430> tbl, [WHERE &lt;\u0443\u0441\u043b\u043e\u0432\u0438\u044f>] ), 1, 1, '') AS string_agg_field;<\/code><\/pre>\n<p>\u0411\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043f\u0440\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u043e \u0441\u0442\u0440\u043e\u043a\u0430\u043c\u0438:<\/p>\n<ol>\n<li>\n<p><a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/t-sql\/functions\/string-functions-transact-sql?view=sql-server-ver15\"><u>MS SQL Server<\/u><\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/postgrespro.ru\/docs\/postgresql\/14\/functions-string\"><u>PostgreSQL<\/u><\/a><\/p>\n<\/li>\n<\/ol>\n<p><strong>XI. \u0424\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0434\u0430\u0442\u043e\u0439 \u0438 \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c<\/strong><\/p>\n<p><strong>\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0434\u0430\u0442\u044b \u0438 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 (\u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f)<\/strong><\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p>MS SQL Server<\/p>\n<\/td>\n<td>\n<p>PostgreSQL<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>GetDate()<\/p>\n<p>SysDateTime()<\/p>\n<p>current_timestamp<\/p>\n<\/td>\n<td>\n<p>clock_timestamp<\/p>\n<p>now()<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p><strong>\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0434\u0430\u0442\u044b<\/strong><\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p>MS SQL Server<\/p>\n<\/td>\n<td>\n<p>PostgreSQL<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>CAST(GetDate() as DATE)<\/p>\n<\/td>\n<td>\n<p>current_date<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0444\u043e\u0440\u043c\u0430\u0442\u0430 \u0434\u0430\u0442\u044b \u0438 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0438\u0437 \u0441\u0442\u0440\u043e\u043a\u0438 public_date:<\/p>\n<p>\u0412 MS SQL Server:<\/p>\n<pre><code class=\"sql\">FORMAT(public_date, 'dd.MM.yyyy HH:mm:ss', 'ru-RU') \u2014 \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0442\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431  convert(varchar(32),convert(datetime,public_date,104),120)<\/code><\/pre>\n<p>\u0412 PostgreSQL:<\/p>\n<pre><code class=\"sql\">to_char(to_timestamp(public_date, 'dd.MM.yyyy hh24.mi'), 'yyyy-mm-dd hh24:mi:ss')<\/code><\/pre>\n<p><strong>\u041f\u0440\u0438\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u0434\u0430\u0442\u044b\/\u0432\u0440\u0435\u043c\u0435\u043d\u0438<\/strong><\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td data-colwidth=\"335\" width=\"335\">\n<p>\u0412 MS SQL Server:<\/p>\n<\/td>\n<td>\n<p>\u0412 PostgreSQL:<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"335\" width=\"335\">\n<p>DateAdd(datepart, count, dt);<\/p>\n<\/td>\n<td>\n<p>dt + (count * interval &#8216;1 datepart&#8217;);<br \/>\u0438\u043b\u0438<br \/>dt + interval &#8216;count datepart&#8217;;<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td colspan=\"2\" data-colwidth=\"335,0\" width=\"335\">\n<p>\u0411\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043f\u0440\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0434\u0430\u0442\u043e\u0439 \u0438 \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c: <\/p>\n<p>1. <a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/t-sql\/functions\/date-and-time-data-types-and-functions-transact-sql?view=sql-server-ver15\"><u>MS SQL Server<\/u><\/a><\/p>\n<p>2. <a href=\"https:\/\/postgrespro.ru\/docs\/postgresql\/14\/functions-datetime\"><u>PostgreSQL<\/u><\/a><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p><strong>XII. \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0441\u0442\u0440\u043e\u043a, \u0437\u0430\u0442\u0440\u043e\u043d\u0443\u0442\u044b\u0445 \u043f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u044b<\/strong><\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p>MS SQL Server<\/p>\n<\/td>\n<td>\n<p>PostgreSQL<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/t-sql\/functions\/rowcount-transact-sql?view=sql-server-ver15\"><u>@@ROWCOUNT<\/u><\/a><\/p>\n<\/td>\n<td>\n<p><a href=\"https:\/\/postgrespro.ru\/docs\/postgresql\/14\/plpgsql-statements\"><u>get diagnostics<\/u><\/a> &lt;\u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f>:=row_count;<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p><strong>XIII. \u0412\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e SQL-\u043a\u043e\u0434\u0430<\/strong><\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p>MS SQL Server<\/p>\n<\/td>\n<td>\n<p>PostgreSQL<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>execute <a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/relational-databases\/system-stored-procedures\/sp-executesql-transact-sql?view=sql-server-ver15\"><u>sp_executesql<\/u><\/a> @sql;<\/p>\n<\/td>\n<td>\n<p><a href=\"https:\/\/postgrespro.ru\/docs\/postgresql\/14\/sql-execute\"><u>execute<\/u><\/a> _sql;<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p><strong>XIV. \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0438 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0442\u0438\u043f\u043e\u0432<\/strong><\/p>\n<p><strong>\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0441\u0442\u0440\u043e\u043a\u0438 \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u043e\u043d\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0447\u0438\u0441\u043b\u043e\u043c<\/strong><\/p>\n<p>\u0412 MS SQL Server:<\/p>\n<p>\u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f <a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/t-sql\/functions\/isnumeric-transact-sql?view=sql-server-ver15\"><u>isnumeric<\/u><\/a>(val)<\/p>\n<p>\u0412 PostgreSQL:<\/p>\n<pre><code class=\"sql\">CREATE OR REPLACE FUNCTION dbo.isnumeric(_input varchar(255) DEFAULT NULL::varchar(255)) RETURNS bit LANGUAGE plpgsql AS $function$ \/* \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438 \u0432\u0445\u043e\u0434\u043d\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0447\u0438\u0441\u043b\u043e\u043c *\/ declare _result bit; begin begin perform _input::numeric; _result:=1::bit; exception when others THEN _result:=0::bit; end; return _result; end; $function$ ;<\/code><\/pre>\n<p><strong>\u0411\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0442\u0438\u043f\u0430<\/strong><\/p>\n<p>\u0412 MS SQL Server:<\/p>\n<pre><code class=\"sql\">try_cast(val as &lt;type>)<\/code><\/pre>\n<p><em>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435.<\/em> try_cast \u0432 MS SQL Server \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 NULL, \u0435\u0441\u043b\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u043c\u0443 \u0442\u0438\u043f\u0443, \u0432 \u0434\u0440\u0443\u0433\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u2014 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043a\u0430\u043a \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 CAST.<\/p>\n<p>\u0412 PostgreSQL \u0435\u0441\u0442\u044c \u0434\u0432\u0430 \u0441\u043f\u043e\u0441\u043e\u0431\u0430:<\/p>\n<p>1) \u0447\u0435\u0440\u0435\u0437 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u043e\u0448\u0438\u0431\u043e\u043a:<\/p>\n<pre><code class=\"sql\">declare _result \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 CAST &lt;type>; ...  BEGIN _result := cast(val as &lt;type>);  exception  when others then  _result :=null; end;<\/code><\/pre>\n<p>2) \u0447\u0435\u0440\u0435\u0437 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0438:<\/p>\n<pre><code class=\"sql\">CREATE OR REPLACE FUNCTION dbo.try_cast(value character varying, typename CHARACTER varying) returns text LANGUAGE plpgsql AS $function$ declare _sql_command text; DECLARE _result text; begin _result=value; _sql_command := 'select cast('||''''|| value||''''||' as '|| typename||');'; BEGIN execute _sql_command; exception when others then _result :=null; end; return _result; end; $function$ ;<\/code><\/pre>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0432 \u0438\u0442\u043e\u0433\u0435 \u043d\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u0432 \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0439 \u0442\u0438\u043f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435.<br \/>\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u043d\u0430 \u0432\u0445\u043e\u0434 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0442\u0435\u043a\u0441\u0442 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0442\u0435\u043a\u0441\u0442.<br \/>\u0415\u0441\u043b\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u043c\u0443 \u0442\u0438\u043f\u0443, \u0442\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f NULL.<\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f (\u0447\u0442\u043e\u0431\u044b \u0431\u044b\u043b\u043e \u043a\u0430\u043a \u0432 MS SQL Server):<\/p>\n<pre><code class=\"sql\">cast(dbo.try_cast(val::text, '&lt;type>') as &lt;type>)<\/code><\/pre>\n<p><strong>XV. DML-\u043a\u043e\u043c\u0430\u043d\u0434\u044b<\/strong><\/p>\n<p><strong>\u041e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445<\/strong><\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u0432 MS SQL Server:<\/p>\n<p>\u041e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u044f Name \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 Production.ScrapReason \u0434\u043b\u044f \u0442\u0435\u0445 \u0441\u0442\u0440\u043e\u043a, \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0435\u0441\u0442\u044c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 Production.WorkOrder \u043f\u043e \u0440\u0430\u0432\u0435\u043d\u0441\u0442\u0432\u0443 ScrapReasonID \u0438 \u0443 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 ScrappedQty \u0431\u043e\u043b\u044c\u0448\u0435 300:<\/p>\n<pre><code class=\"sql\">UPDATE   sr SET   sr.Name = 'Name' OUTPUT   deleted.* , inserted.* FROM Production.ScrapReas sr   JOIN Production.WorkOrder wo ON (sr.ScrapReasonID = wo.ScrapReasonID)                                   AND (wo.ScrappedQty > 300);<\/code><\/pre>\n<p>\u041a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e OUTPUT \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043e\u0431 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0438.<\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u0432 PostgreSQL:<\/p>\n<p>\u041e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u044f Name \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 production.scrapreason \u0434\u043b\u044f \u0442\u0435\u0445 \u0441\u0442\u0440\u043e\u043a, \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0435\u0441\u0442\u044c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 production.workorder \u043f\u043e \u0440\u0430\u0432\u0435\u043d\u0441\u0442\u0432\u0443 scrapreasonid \u0438 \u0443 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 scrappedqty \u0431\u043e\u043b\u044c\u0448\u0435 300:<\/p>\n<pre><code class=\"sql\">update production.scrapreason as sr set sr.Name = 'Name' from production.workorder as wo where (sr.scrapreasoid = wo.scrapreasonoid) and (wo.scrappedqty > 300) returning *;<\/code><\/pre>\n<p>\u041a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e returning \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043e\u0431 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0438.<\/p>\n<p>\u0411\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043e \u043a\u043e\u043c\u0430\u043d\u0434\u0435 UPDATE:<\/p>\n<ol>\n<li>\n<p><a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/t-sql\/queries\/update-transact-sql?view=sql-server-ver15\"><u>MS SQL Server<\/u><\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/postgrespro.ru\/docs\/postgresql\/14\/sql-update\"><u>PostgreSQL<\/u><\/a><\/p>\n<\/li>\n<\/ol>\n<p><strong>\u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445<\/strong><\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u0432 MS SQL Server:<\/p>\n<p>\u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0438\u0437 \u0442\u0430\u0431\u043b\u0438\u0446\u044b Sales.SalesPersonQuotaHistory \u0442\u0435\u0445 \u0437\u0430\u043f\u0438\u0441\u0435\u0439, \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0435\u0441\u0442\u044c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 Sales.SalesPerson \u043f\u043e \u0440\u0430\u0432\u0435\u043d\u0441\u0442\u0432\u0443 BusinessEntityID \u0438 \u0443 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 SalesYTD \u0431\u043e\u043b\u044c\u0448\u0435 2500000.00:<\/p>\n<pre><code class=\"sql\">DELETE FROM spqh OUTPUT deleted.* FROM Sales.SalesPersonQuotaHistory spqh   INNER JOIN Sales.SalesPerson sp ON (spqh.BusinessEntityID = sp.BusinessEntityID) WHERE   (sp.SalesYTD > 2500000.00);<\/code><\/pre>\n<p>\u041a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e OUTPUT \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043e\u0431 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0438.<\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u0432 PostgreSQL:<\/p>\n<p>\u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0438\u0437 \u0442\u0430\u0431\u043b\u0438\u0446\u044b sales.salespersonquotahistory \u0442\u0435\u0445 \u0437\u0430\u043f\u0438\u0441\u0435\u0439, \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0435\u0441\u0442\u044c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 sales.salesperson \u043f\u043e \u0440\u0430\u0432\u0435\u043d\u0441\u0442\u0432\u0443 businessentitid \u0438 \u0443 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 salesytd \u0431\u043e\u043b\u044c\u0448\u0435 2500000.00:<\/p>\n<pre><code class=\"sql\">delete from sales.salespersonquotahistory AS spqh using sales.salesperson AS sp where (spqh.businessentityid = sp.businessentitid) and (sp.salesytd > 2500000.00) returning *;<\/code><\/pre>\n<p>\u041a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e returning \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043e\u0431 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0438.<\/p>\n<p>\u0411\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043e \u043a\u043e\u043c\u0430\u043d\u0434\u0435 DELETE:<\/p>\n<ol>\n<li>\n<p><a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/t-sql\/statements\/delete-transact-sql?view=sql-server-ver15\"><u>MS SQL Server<\/u><\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/postgrespro.ru\/docs\/postgresql\/14\/sql-delete\"><u>PostgreSQL<\/u><\/a><\/p>\n<\/li>\n<\/ol>\n<p><strong>\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0438\u0437\u043c\u0435\u043d\u0451\u043d\u043d\u044b\u0445 \u0437\u0430\u043f\u0438\u0441\u0435\u0439<\/strong><\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p>\u0412 MS SQL Server:<\/p>\n<\/td>\n<td>\n<p>\u0412 PostgreSQL:<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>insert\/update\/delete \u0442\u0430\u0431\u043b\u0438\u0446\u0430<br \/> Output deleted\/inserted.&lt;\u0441\u0442\u043e\u043b\u0431\u0435\u0446><br \/> into [@\/#] &lt;\u0442\u0430\u0431\u043b\u0438\u0446\u0430><br \/> Values|From &lt;\u0437\u0430\u043f\u0440\u043e\u0441><\/p>\n<\/td>\n<td>\n<p>insert\/update\/delete \u0442\u0430\u0431\u043b\u0438\u0446\u0430<br \/> values()|from &lt;\u0437\u0430\u043f\u0440\u043e\u0441>|using &lt;\u0437\u0430\u043f\u0440\u043e\u0441><br \/> returning *, \u0441\u0442\u043e\u043b\u0431\u0435\u0446\/\u0441\u0442\u043e\u043b\u0431\u0446\u044b<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td colspan=\"2\">\n<p>\u0412 update \u0435\u0441\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u0442\u043e\u043b\u044c\u043a\u043e \u043a inserted.<\/p>\n<p><em>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435.<\/em> \u0412 PostgreSQL \u043d\u0435 \u043d\u0443\u0436\u043d\u0430 \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u0430\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0438\u0437\u043c\u0435\u043d\u0451\u043d\u043d\u044b\u0445 \u0437\u0430\u043f\u0438\u0441\u0435\u0439.<\/p>\n<p>\u0411\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e:<\/p>\n<p>1. <a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/t-sql\/queries\/output-clause-transact-sql?view=sql-server-ver15\"><u>OUTPUT \u0432 MS SQL Server<\/u><\/a><\/p>\n<p>2. <a href=\"https:\/\/postgrespro.ru\/docs\/postgresql\/14\/dml-returning\"><u>returning \u0432 PostgreSQL<\/u><\/a><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p><strong>\u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0434\u0443\u0431\u043b\u0438\u043a\u0430\u0442\u043e\u0432 (\u0434\u0443\u0431\u043b\u0438\u0440\u0443\u044e\u0449\u0438\u0445 \u0441\u0442\u0440\u043e\u043a):<\/strong><\/p>\n<p>\u0412 MS SQL Server:<\/p>\n<pre><code class=\"sql\">with dbl_in_stage as ( select row_number() over (partition by &lt;field_1>, ..., &lt;field_N> order by 1) as rn from &lt;\u0441\u0445\u0435\u043c\u0430>.&lt;\u0442\u0430\u0431\u043b\u0438\u0446\u0430> as stg ) delete from dbl_in_stage where rn > 1;<\/code><\/pre>\n<p>\u0412 PostgreSQL:<\/p>\n<pre><code class=\"sql\">with x as ( select a, ctid, row_number() over(partition by a order by ctid) rn from t ) delete from t using x where t.a = x.a and t.ctid = x.ctid and x.rn > 1;<\/code><\/pre>\n<p>\u0438\u043b\u0438 \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442:<\/p>\n<pre><code class=\"sql\">delete from &lt;\u0441\u0445\u0435\u043c\u0430>.&lt;\u0442\u0430\u0431\u043b\u0438\u0446\u0430> where ctid=any(   array(select unnest(ctids[2:])          from (           select array_agg(             ctid order by string_to_array(               regexp_replace(ctid::text, E'\\\\(|\\\\)','','g'),',')::bigint[]) ctids            FROM &lt;\u0441\u0445\u0435\u043c\u0430>.&lt;\u0442\u0430\u0431\u043b\u0438\u0446\u0430> as T group by T::text) as T)::tid[]);<\/code><\/pre>\n<p><em>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435.<\/em> \u041e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u2014 \u0432\u043d\u0435\u0441\u0442\u0438 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u043a\u043b\u044e\u0447, \u0442\u0430\u043a \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430 \u0441 \u043c\u0435\u0442\u0430\u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u0442 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u043d\u0430 \u0441\u0438\u0441\u0442\u0435\u043c\u0443.<\/p>\n<p>\u041f\u0440\u0438 \u043d\u0430\u043b\u0438\u0447\u0438\u0438 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430 \u0443\u0434\u0430\u043b\u044f\u0442\u044c \u0434\u0443\u0431\u043b\u0438\u043a\u0430\u0442\u044b \u0432 PostgreSQL \u043c\u043e\u0436\u043d\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"sql\">delete from &lt;\u0441\u0445\u0435\u043c\u0430>.&lt;\u0442\u0430\u0431\u043b\u0438\u0446\u0430> where &lt;\u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u043a\u043b\u044e\u0447> in (select &lt;\u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u043a\u043b\u044e\u0447> from ( select *, row_number() over (partition by &lt;field_1>, ..., &lt;field_N> order by 1) as rn from &lt;\u0441\u0445\u0435\u043c\u0430>.&lt;\u0442\u0430\u0431\u043b\u0438\u0446\u0430> ) as tbl where rn > 1);<\/code><\/pre>\n<p><strong>XVI. DDL-\u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u043c\u0438<\/strong><\/p>\n<p><strong>\u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0441 \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u043e\u0439<\/strong><\/p>\n<p>\u0412 MS SQL Server:<\/p>\n<p>\u0414\u043b\u044f \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b:<\/p>\n<pre><code class=\"sql\">DROP TABLE IF EXISTS &lt;schema>.&lt;table>;<\/code><\/pre>\n<p>\u0414\u043b\u044f \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b:<\/p>\n<pre><code class=\"sql\">IF EXISTS(SELECT [name] FROM tempdb.sys.tables WHERE [name] like '#&lt;table>%') BEGIN DROP TABLE #&lt;table>; END;<\/code><\/pre>\n<p>\u0414\u043b\u044f \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e\u0439 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b:<\/p>\n<pre><code class=\"sql\">IF EXISTS(SELECT [name] FROM tempdb.sys.tables WHERE [name] like '##&lt;table>%') BEGIN DROP TABLE ##&lt;table>; END;<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c:<\/p>\n<ol>\n<li>\n<p>#&lt;table> \u2014 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u0430\u044f \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u0438\u0434\u043d\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0441\u0435\u0441\u0441\u0438\u0438<\/p>\n<\/li>\n<li>\n<p>##&lt;table> \u2014 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u0430\u044f \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u0438\u0434\u043d\u0430 \u0432\u0441\u0435\u043c \u043f\u043e\u043a\u0430 \u043e\u043d\u0430 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442<\/p>\n<\/li>\n<\/ol>\n<p>\u0412\u0441\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0436\u0438\u0432\u0443\u0442, \u043b\u0438\u0431\u043e \u043f\u043e\u043a\u0430 \u0430\u043a\u0442\u0438\u0432\u043d\u0430 \u0441\u0435\u0441\u0441\u0438\u044f, \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043e\u043d\u0438 \u0431\u044b\u043b\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u044b, \u043b\u0438\u0431\u043e \u043f\u043e\u043a\u0430 \u0438\u0445 \u044f\u0432\u043d\u043e \u043d\u0435 \u0443\u0434\u0430\u043b\u044f\u0442.<\/p>\n<p>\u0412 PostgreSQL:<\/p>\n<p>\u0414\u043b\u044f \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b:<\/p>\n<pre><code class=\"sql\">drop table if exists &lt;schema>.&lt;table>;<\/code><\/pre>\n<p>\u0414\u043b\u044f \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b:<\/p>\n<pre><code class=\"sql\">drop table if exists &lt;table>;<\/code><\/pre>\n<p>\u0411\u043e\u043b\u0435\u0435 \u0434\u0435\u0442\u0430\u043b\u044c\u043d\u043e \u043f\u0440\u043e \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0442\u0430\u0431\u043b\u0438\u0446:<\/p>\n<ol>\n<li>\n<p><a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/t-sql\/statements\/drop-table-transact-sql?view=sql-server-ver15\"><u>MS SQL Server<\/u><\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/postgrespro.ru\/docs\/postgresql\/14\/sql-droptable\"><u>PostgreSQL<\/u><\/a><\/p>\n<\/li>\n<\/ol>\n<p><strong>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0447\u0435\u0440\u0435\u0437 \u0432\u044b\u0431\u043e\u0440\u043a\u0443<\/strong><\/p>\n<p>\u0412 MS SQL Server:<\/p>\n<p>\u0414\u043b\u044f \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b:<\/p>\n<pre><code class=\"sql\">select ... into &lt;table> from \u2026<\/code><\/pre>\n<p>\u0414\u043b\u044f \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b:<\/p>\n<pre><code class=\"sql\">select ... into #&lt;table> from \u2026<\/code><\/pre>\n<p>\u0412 PostgreSQL:<\/p>\n<p>\u0414\u043b\u044f \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b:<\/p>\n<pre><code class=\"sql\">create table &lt;table> as select ...<\/code><\/pre>\n<p>\u0414\u043b\u044f \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b:<\/p>\n<pre><code class=\"sql\">create temp table &lt;table> as select \u2026<\/code><\/pre>\n<p>\u0411\u043e\u043b\u0435\u0435 \u0434\u0435\u0442\u0430\u043b\u044c\u043d\u043e \u043f\u0440\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0442\u0430\u0431\u043b\u0438\u0446 \u0447\u0435\u0440\u0435\u0437 \u0432\u044b\u0431\u043e\u0440\u043a\u0443:<\/p>\n<ol>\n<li>\n<p><a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/t-sql\/queries\/select-into-clause-transact-sql?view=sql-server-ver15\"><u>MS SQL Server<\/u><\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/postgrespro.ru\/docs\/postgresql\/14\/sql-createtableas\"><u>PostgreSQL<\/u><\/a><\/p>\n<\/li>\n<\/ol>\n<p><strong>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435\/\u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0434\u043b\u044f \u043a\u043e\u043b\u043e\u043d\u043a\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u044b<\/strong><\/p>\n<p>\u0412 MS SQL Server:<\/p>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435:<\/p>\n<pre><code class=\"sql\">ALTER TABLE &lt;\u0441\u0445\u0435\u043c\u0430>.&lt;\u0442\u0430\u0431\u043b\u0438\u0446\u0430> ADD CONSTRAINT &lt;\u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435_\u043f\u0440\u0430\u0432\u0438\u043b\u0430> DEFAULT &lt;\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435_\u043f\u043e_\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e> FOR &lt;\u043f\u043e\u043b\u0435>;<\/code><\/pre>\n<p>\u0412\u044b\u0431\u043e\u0440\u043a\u0430 \u0432\u0441\u0435\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e:<\/p>\n<pre><code class=\"sql\">SELECT SCHEMA_NAME(t.[schema_id]) AS sch , t.name AS tbl , col.name AS colname , dc.definition AS def FROM sys.default_constraints dc   INNER JOIN sys.columns col ON dc.parent_object_id = col.[object_id]   INNER JOIN sys.tables t ON t.[object_id] = col.[object_id];<\/code><\/pre>\n<p>\u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435:<\/p>\n<pre><code class=\"sql\">DROP DEFAULT IF EXISTS &lt;\u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435_\u043f\u0440\u0430\u0432\u0438\u043b\u0430>;<\/code><\/pre>\n<p>\u0418\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0447\u0435\u0440\u0435\u0437 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435.<\/p>\n<p>\u0412 PostgreSQL:<\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435:<\/p>\n<pre><code class=\"sql\">alter table &lt;\u0441\u0445\u0435\u043c\u0430>.&lt;\u0442\u0430\u0431\u043b\u0438\u0446\u0430> alter column &lt;\u043f\u043e\u043b\u0435> set default &lt;\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435_\u043f\u043e_\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e>;<\/code><\/pre>\n<p>\u0412\u044b\u0431\u043e\u0440\u043a\u0430 \u0432\u0441\u0435\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e:<\/p>\n<pre><code class=\"sql\">select col.table_schema, col.table_name, col.column_name, col.column_default from information_schema.columns as col;<\/code><\/pre>\n<p>\u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435:<\/p>\n<pre><code class=\"sql\">alter table &lt;\u0441\u0445\u0435\u043c\u0430>.&lt;\u0442\u0430\u0431\u043b\u0438\u0446\u0430> alter column &lt;\u043f\u043e\u043b\u0435> drop default;<\/code><\/pre>\n<p><strong>\u0418\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0442\u0438\u043f\u0430 \u043a\u043e\u043b\u043e\u043d\u043a\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u044b<\/strong><\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p>\u0412 MS SQL Server:<\/p>\n<\/td>\n<td>\n<p>\u0412 PostgreSQL:<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>ALTER TABLE<br \/> &lt;\u0441\u0445\u0435\u043c\u0430>.&lt;\u0442\u0430\u0431\u043b\u0438\u0446\u0430><br \/> ALTER COLUMN &lt;\u043f\u043e\u043b\u0435><br \/> &lt;\u043d\u043e\u0432\u044b\u0439_\u0442\u0438\u043f> [NULL|NOT NULL];<\/p>\n<\/td>\n<td>\n<p>alter table<br \/> &lt;\u0441\u0445\u0435\u043c\u0430>.&lt;\u0442\u0430\u0431\u043b\u0438\u0446\u0430><br \/> alter column &lt;\u043f\u043e\u043b\u0435><br \/> type &lt;\u043d\u043e\u0432\u044b\u0439_\u0442\u0438\u043f>;<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td colspan=\"2\">\n<p><em>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435.<\/em> \u0415\u0441\u043b\u0438 \u0443 \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c\u043e\u0433\u043e \u0441\u0442\u043e\u043b\u0431\u0446\u0430 \u0435\u0441\u0442\u044c \u043a\u0430\u043a\u0438\u0435-\u043b\u0438\u0431\u043e \u043a\u043e\u043d\u0441\u0442\u0440\u0435\u0439\u043d\u0442\u044b \u0438\u043b\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e, \u0442\u043e \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0443\u0436\u043d\u043e \u0438\u0445 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c, \u0430 \u0437\u0430\u0442\u0435\u043c \u0443\u0434\u0430\u043b\u0438\u0442\u044c. \u0412\u0435\u0440\u043d\u0443\u0442\u044c \u0438\u0445 \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0441\u043b\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0442\u0438\u043f\u0430.<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p><strong>\u041f\u0435\u0440\u0435\u043d\u043e\u0441 \u0430\u0432\u0442\u043e\u0438\u043d\u043a\u0440\u0435\u043c\u0435\u043d\u0442\u043d\u044b\u0445 \u043f\u043e\u043b\u0435\u0439<\/strong><\/p>\n<p>\u0412 MS SQL Server \u0434\u0435\u043b\u0430\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441 \u0432\u0438\u0434\u0430:<\/p>\n<pre><code class=\"sql\">SELECT   'do $$ declare start_with_val bigint; declare sql_statement varchar; begin start_with_val := coalesce((select max(' + c.[name] + ') from ' + s.[name] + '.' + o.[name] + '),0)+1; sql_statement := ''alter table ' + s.[name] + '.' + o.[name] + ' alter ' + c.[name] + ' add generated by default as identity (start with '' || cast(start_with_val as varchar)||'');''; execute sql_statement; end; $$;' AS plsql_statement --select distinct s.name FROM   sys.all_columns c   INNER JOIN sys.all_objects o ON o.[object_id] = c.[object_id]   INNER JOIN sys.schemas s ON s.[schema_id] = o.[schema_id] WHERE   is_identity &lt;> 0   AND SCHEMA_NAME(o.[schema_id]) &lt;> 'sys'   AND o.[type] = 'U';<\/code><\/pre>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"sql\">do $$  declare  start_with_val bigint;  declare  sql_statement varchar;  begin start_with_val := coalesce((select  max(ID) from  dbo.ExchangeQueue),0)+1;   sql_statement := 'alter table  dbo.ExchangeQueue alter ID  add generated by  default as identity  (start with '  ||  cast(start_with_val  as varchar)||');';   EXECUTE sql_statement;   end;  $$;<\/code><\/pre>\n<p>\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u0441\u043a\u0440\u0438\u043f\u0442\u044b \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 PostgreSQL.<\/p>\n<p><strong>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0430\u0432\u0442\u043e\u0438\u043d\u043a\u0440\u0435\u043c\u0435\u043d\u0442\u043d\u044b\u0445 \u043f\u043e\u043b\u0435\u0439<\/strong><\/p>\n<p>\u0412 MS SQL Server:<\/p>\n<pre><code class=\"sql\">ALTER TABLE [\u0441\u0445\u0435\u043c\u0430].[\u0442\u0430\u0431\u043b\u0438\u0446\u0430] ADD   &lt;IDENTITY-\u043f\u043e\u043b\u0435> bigint IDENTITY(1, 1) NOT NULL;<\/code><\/pre>\n<p>\u0412 PostgreSQL:<\/p>\n<pre><code class=\"sql\">do $$   DECLARE start_with_val bigint;   DECLARE sql_statement varchar;   BEGIN  start_with_val := coalesce((select  max(&lt;IDENTITY-\u043f\u043e\u043b\u0435>) from  &lt;\u0441\u0445\u0435\u043c\u0430>.&lt;\u0442\u0430\u0431\u043b\u0438\u0446\u0430>),0)+1;   sql_statement := 'alter table &lt;\u0441\u0445\u0435\u043c\u0430>.&lt;\u0442\u0430\u0431\u043b\u0438\u0446\u0430> alter &lt;IDENTITY-\u043f\u043e\u043b\u0435> add generated by  default as identity (start with ' || cast(start_with_val  as varchar)||');';   EXECUTE sql_statement;  END;  $$;<\/code><\/pre>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td colspan=\"2\">\n<p>\u0411\u043e\u043b\u0435\u0435 \u0434\u0435\u0442\u0430\u043b\u044c\u043d\u043e \u043f\u0440\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0442\u0430\u0431\u043b\u0438\u0446:<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/t-sql\/statements\/create-table-transact-sql?view=sql-server-ver15\"><u>MS SQL Server<\/u><\/a><\/p>\n<\/td>\n<td>\n<p><a href=\"https:\/\/postgrespro.ru\/docs\/postgresql\/14\/sql-createtable\"><u>PostgreSQL<\/u><\/a><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td colspan=\"2\">\n<p>\u0411\u043e\u043b\u0435\u0435 \u0434\u0435\u0442\u0430\u043b\u044c\u043d\u043e \u043f\u0440\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0442\u0430\u0431\u043b\u0438\u0446:<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/t-sql\/statements\/alter-table-transact-sql?view=sql-server-ver15\"><u>MS SQL Server<\/u><\/a><\/p>\n<\/td>\n<td>\n<p><a href=\"https:\/\/postgrespro.ru\/docs\/postgresql\/14\/sql-altertable\"><u>PostgreSQL<\/u><\/a><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p><strong>XVII. \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f<\/strong><\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p>\u0412 MS SQL Server:<\/p>\n<\/td>\n<td>\n<p>\u0412 PostgreSQL:<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>CREATE OR ALTER VIEW <\/p>\n<p>[\u0441\u0445\u0435\u043c\u0430].[\u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435_\u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f] <\/p>\n<p>AS<br \/> \u2026<\/p>\n<\/td>\n<td>\n<p>create or replace view <\/p>\n<p>&lt;\u0441\u0445\u0435\u043c\u0430>.&lt;\u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435_\u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f> <\/p>\n<p>as<br \/> \u2026<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td colspan=\"2\">\n<p><em>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435.<\/em> \u0412 PostgreSQL \u043b\u0443\u0447\u0448\u0435 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0443\u0434\u0430\u043b\u044f\u0442\u044c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435, \u0430 \u043f\u043e\u0442\u043e\u043c \u0437\u0430\u043d\u043e\u0432\u043e \u0435\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c, \u0435\u0441\u043b\u0438 \u043d\u0430\u0431\u043e\u0440 \u043f\u043e\u043b\u0435\u0439 \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0438\u043b\u0438 \u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u0432\u044b\u0445\u043e\u0434\u043d\u044b\u0445 \u043f\u043e\u043b\u0435\u0439, \u0438\u043d\u0430\u0447\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0443 \u043f\u0440\u0438 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0438 \u043a \u0438\u0437\u043c\u0435\u043d\u0451\u043d\u043d\u043e\u043c\u0443 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044e.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td colspan=\"2\">\n<p>\u0411\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043f\u0440\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0439:<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/t-sql\/statements\/create-view-transact-sql?view=sql-server-ver15\"><u>MS SQL Server<\/u><\/a><\/p>\n<\/td>\n<td>\n<p><a href=\"https:\/\/postgrespro.ru\/docs\/postgresql\/14\/sql-createview\"><u>PostgreSQL<\/u><\/a><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p><strong>XVIII. \u041f\u043e\u0441\u0442\u0440\u043e\u0447\u043d\u0430\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0441\u0442\u0440\u043e\u043a \u0432 \u043d\u0430\u0431\u043e\u0440\u0435<\/strong><\/p>\n<p>\u0412 MS SQL Server:<\/p>\n<pre><code class=\"sql\">--\u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 @field_1, ...@field_N  DECLARE &lt;\u043a\u0443\u0440\u0441\u043e\u0440> CURSOR LOCAL FOR &lt;SELECT>;  OPEN &lt;\u043a\u0443\u0440\u0441\u043e\u0440>;  FETCH NEXT FROM &lt;\u043a\u0443\u0440\u0441\u043e\u0440> INTO @field_1, ...@field_N;  WHILE (@@FETCH_STATUS = 0) BEGIN --\u043e\u043f\u0435\u0440\u0438\u0440\u0443\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 @field_1, ...@field_N ... FETCH NEXT FROM &lt;\u043a\u0443\u0440\u0441\u043e\u0440> INTO @field_1, ...@field_N; END  CLOSE &lt;\u043a\u0443\u0440\u0441\u043e\u0440>; DEALLOCATE &lt;\u043a\u0443\u0440\u0441\u043e\u0440>;<\/code><\/pre>\n<p>\u0412 PostgreSQL:<\/p>\n<pre><code class=\"sql\">do $$ declare _val record; begin  drop table if exists _tmp_tbl;  create temp table _tmp_tbl as &lt;select> for _val in (select field_1, ..., field_n from_tmp_tbl) loop --\u043c\u043e\u0436\u043d\u043e \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c\u0441\u044f \u043a \u043b\u044e\u0431\u043e\u043c\u0443 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u043c\u0443 \u0440\u0430\u043d\u0435\u0435 \u043f\u043e\u043b\u044e \u0447\u0435\u0440\u0435\u0437 _val.&lt;\u043f\u043e\u043b\u0435>. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, _val.&lt;field_1> end loop; end $$<\/code><\/pre>\n<p><strong>XIX. \u0421\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438<\/strong><\/p>\n<p><strong>\u0422\u0435\u043a\u0443\u0449\u0438\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c<\/strong><\/p>\n<p>\u0412 MS SQL Server \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f <a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/t-sql\/functions\/current-user-transact-sql?view=sql-server-ver15\"><u>CURRENT_USER<\/u><\/a>().<\/p>\n<p>\u0412 PostgreSQL:<\/p>\n<ol>\n<li>\n<p>session_user \u2014 \u043f\u043e\u0434 \u043a\u0430\u043a\u0438\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c \u043e\u0442\u043a\u0440\u044b\u0442\u0430 \u0441\u0435\u0441\u0441\u0438\u044f<\/p>\n<\/li>\n<li>\n<p>current_user (\u0438\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u043e user) \u2014 \u043f\u043e\u0434 \u043a\u0430\u043a\u0438\u043c \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u043e\u043c (\u0440\u043e\u043b\u044c\u044e) \u0438\u0434\u0451\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 (session_user \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u2014 \u0437\u0434\u0435\u0441\u044c \u0432\u0430\u0436\u043d\u043e, \u043f\u043e\u0434 \u043a\u0430\u043a\u0438\u043c \u043f\u0440\u0430\u0432\u043e\u043c \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435)<\/p>\n<\/li>\n<\/ol>\n<p><strong>\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0438\u043c\u0435\u043d\u0438 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 \u0438 IP-\u0430\u0434\u0440\u0435\u0441\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0421\u0423\u0411\u0414<\/strong><\/p>\n<p>\u0412 MS SQL Server:<\/p>\n<p>\u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e\u0431 IP-\u0430\u0434\u0440\u0435\u0441\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0421\u0423\u0411\u0414:<\/p>\n<pre><code class=\"sql\">SELECT   CONNECTIONPROPERTY(' net_transport') AS net_transport , CONNECTIONPROPERTY(' protocol_type') AS protocol_type , CONNECTIONPROPERTY(' auth_scheme') AS auth_scheme , CONNECTIONPROPERTY(' local_net_address') AS local_net_address , CONNECTIONPROPERTY(' local_tcp_port') AS local_tcp_port , CONNECTIONPROPERTY(' client_net_address') AS client_net_address;<\/code><\/pre>\n<p>\u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 \u0421\u0423\u0411\u0414:<\/p>\n<pre><code class=\"sql\">SELECT @@SERVERNAME;<\/code><\/pre>\n<p>\u0412 PostgreSQL:<\/p>\n<p>\u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c IP-\u0430\u0434\u0440\u0435\u0441 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0421\u0423\u0411\u0414:<\/p>\n<pre><code class=\"sql\">do $$ declare title varchar(100) :=host(inet_server_addr()); begin raise notice '%', title; end; $$;<\/code><\/pre>\n<p>\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 \u0421\u0423\u0411\u0414 \u043f\u043e\u043a\u0430 \u043d\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043e.<\/p>\n<p>\u0411\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043f\u0440\u043e \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438:<\/p>\n<ol>\n<li>\n<p><a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/t-sql\/functions\/security-functions-transact-sql?view=sql-server-ver15\"><u>MS SQL Server<\/u><\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/postgrespro.ru\/docs\/postgresql\/14\/functions-info\"><u>PostgreSQL<\/u><\/a><\/p>\n<\/li>\n<\/ol>\n<p><strong>XX. \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0438 \u0432\u044b\u0437\u043e\u0432 \u0445\u0440\u0430\u043d\u0438\u043c\u043e\u0439 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u044b<\/strong><\/p>\n<p><strong>\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0445\u0440\u0430\u043d\u0438\u043c\u043e\u0439 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u044b<\/strong><\/p>\n<p>\u0412 <a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/t-sql\/statements\/create-procedure-transact-sql?view=sql-server-ver15\">MS SQL Server<\/a>:<\/p>\n<pre><code class=\"sql\">CREATE OR ALTER PROCEDURE [\u0441\u0445\u0435\u043c\u0430].[\u043d\u0430\u0437\u0430\u043d\u0438\u0435_\u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u044b] &lt;\u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f_1> &lt;\u0442\u0438\u043f_1>[=&lt;\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435_\u043f\u043e_\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e_1>], ... AS BEGIN ... END<\/code><\/pre>\n<p>\u0412 <a href=\"https:\/\/postgrespro.ru\/docs\/postgresql\/14\/sql-createprocedure\">PostgreSQL<\/a>:<\/p>\n<pre><code class=\"sql\">CREATE OR REPLACE PROCEDURE &lt;\u0441\u0445\u0435\u043c\u0430>.&lt;\u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435_\u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u044b> ( [INOUT] &lt;\u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f_1> &lt;\u0442\u0438\u043f_1>[=&lt;\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435_\u043f\u043e_\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e1>], ... ) LANGUAGE plpgsql AS $body$ [&lt;\u041e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445>] BEGIN ... END; $body$ ;<\/code><\/pre>\n<p><strong>\u0412\u044b\u0437\u043e\u0432 \u0445\u0440\u0430\u043d\u0438\u043c\u043e\u0439 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u044b<\/strong><\/p>\n<p>\u0412 MS SQL Server:<\/p>\n<pre><code class=\"sql\">EXEC &lt;\u0441\u0445\u0435\u043c\u0430>.&lt;\u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0430>  &lt;\u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f_1>=&lt;\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435_1>, ..., &lt;\u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f_OUTPUT> OUT[PUT];<\/code><\/pre>\n<p>\u0412 PostgreSQL:<\/p>\n<pre><code class=\"sql\">call &lt;\u0441\u0445\u0435\u043c\u0430>.&lt;\u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0430> (   &lt;\u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f_1>=&lt;\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435_1>, ..., &lt;\u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f_OUTPUT>);<\/code><\/pre>\n<p><strong>XXI. \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0441\u043a\u0430\u043b\u044f\u0440\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438<\/strong><\/p>\n<p>\u0412 <a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/t-sql\/statements\/create-function-transact-sql?view=sql-server-ver15\">MS SQL Server<\/a>:<\/p>\n<pre><code class=\"sql\">CREATE OR ALTER FUNCTION [\u0441\u0445\u0435\u043c\u0430].[\u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435_\u0444\u0443\u043d\u043a\u0446\u0438\u0438] (&lt;\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440_1> &lt;\u0442\u0438\u043f_1>[=&lt;\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435_\u043f\u043e_\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e_1>], ...) RETURNS &lt;\u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0439_\u0442\u0438\u043f> AS BEGIN ... RETURN ... END<\/code><\/pre>\n<p>\u0412 <a href=\"https:\/\/postgrespro.ru\/docs\/postgresql\/14\/sql-createfunction\">PostgreSQL<\/a>:<\/p>\n<pre><code class=\"sql\">CREATE OR REPLACE FUNCTION &lt;\u0441\u0445\u0435\u043c\u0430>.&lt;\u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435_\u0444\u0443\u043d\u043a\u0446\u0438\u0438> (&lt;\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440_1> &lt;\u0442\u0438\u043f_1>[=&lt;\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435_\u043f\u043e_\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e_1>], ...) RETURNS &lt;\u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0439_\u0442\u0438\u043f> LANGUAGE plpgsql AS $body$ [&lt;\u041e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445>] begin ... return ( select ... ); end; $body$ ;<\/code><\/pre>\n<p><strong>XXII. \u041f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 \u0442\u0430\u0431\u043b\u0438\u0447\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f (\u0432\u044b\u0432\u043e\u0434 \u0442\u0430\u0431\u043b\u0438\u0446\u044b)<\/strong><\/p>\n<p>\u0412 MS SQL Server:<\/p>\n<pre><code class=\"sql\">CREATE OR ALTER PROCEDURE [\u0441\u0445\u0435\u043c\u0430].[\u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435_\u0445\u0440\u0430\u043d\u0438\u043c\u043e\u0439_\u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u044b] &lt;\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440_1> &lt;\u0442\u0438\u043f_1>, ..., &lt;\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440_N> &lt;\u0442\u0438\u043f_N> AS BEGIN ... SELECT ... END<\/code><\/pre>\n<p>\u0412 PostgreSQL:<\/p>\n<pre><code class=\"sql\">create or replace function &lt;\u0441\u0445\u0435\u043c\u0430>.&lt;\u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435_\u0444\u0443\u043d\u043a\u0446\u0438\u0438> (&lt;\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440_1> &lt;\u0442\u0438\u043f_1>, ..., &lt;\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440_N> &lt;\u0442\u0438\u043f_N>) return table (&lt;\u043f\u043e\u043b\u0435_1> &lt;\u0442\u0438\u043f_1>, ..., &lt;\u043f\u043e\u043b\u0435_N> &lt;\u0442\u0438\u043f_N>) language 'plpgsql' as $body$ [&lt;\u041e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445>] begin return query (select ....); end; $body$;<\/code><\/pre>\n<p><strong>XXIII. DML-\u0442\u0440\u0438\u0433\u0433\u0435\u0440\u044b<\/strong><\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u0432 MS SQL Server:<\/p>\n<pre><code class=\"sql\">CREATE TRIGGER [info].[tr_isupoll_question_text_last_update_trigger] ON [info].[isupoll_question_text] FOR UPDATE AS UPDATE   info.isupoll_question_text SET   last_update_date = GETDATE() , last_update_user = SUSER_NAME() FROM   info.isupoll_question_text ds   INNER JOIN INSERTED i ON    ds.isupoll_question_text_id = i.isupoll_question_text_id;<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u0442\u0440\u0438\u0433\u0433\u0435\u0440 tr_isupoll_question_text_last_update_trigger \u0434\u043b\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u044b\u00a0 info.isupoll_question_text \u043f\u043e\u0441\u043b\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u043b\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c\u044b\u0445 \u0441\u0442\u0440\u043e\u043a \u043f\u0440\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0442\u0435\u043a\u0443\u0449\u0438\u0435 \u0434\u0430\u0442\u0443, \u0432\u0440\u0435\u043c\u044f \u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e.<\/p>\n<pre><code class=\"sql\">DROP TRIGGER IF EXISTS [tr_isupoll_question_text_last_update_trigger]  on [info].[isupoll_question_text];<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u0443\u0434\u0430\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u0440\u0438\u0433\u0433\u0435\u0440 tr_isupoll_question_text_last_update_trigger \u0434\u043b\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u044b info.isupoll_question_text<\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u0432 PostgreSQL:<\/p>\n<pre><code class=\"sql\">CREATE OR REPLACE FUNCTION dbo.update_mod() RETURNS trigger LANGUAGE plpgsql AS $function$ begin new.last_update_date=now();  new.last_update_user=session_user;  return new; end; $function$ ;<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f dbo.update_mod(), \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0434\u0432\u0430 \u043f\u043e\u043b\u044f \u0442\u0435\u043a\u0443\u0449\u0438\u043c\u0438 \u0434\u0430\u0442\u043e\u0439, \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c \u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e.<\/p>\n<pre><code class=\"sql\">create trigger tr_isupoll_question_text_last_update_trigger before update  on info.isupoll_question_text for each row execute function dbo.update_mod();<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u0442\u0440\u0438\u0433\u0433\u0435\u0440 tr_isupoll_question_text_last_update_trigger \u0434\u043b\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u044b\u00a0 info.isupoll_question_text \u0434\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 dbo.update_mod().<\/p>\n<pre><code class=\"sql\">drop trigger if exists tr_isupoll_question_text_last_update_trigger  on info.isupoll_question_text;<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u0443\u0434\u0430\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u0440\u0438\u0433\u0433\u0435\u0440 tr_isupoll_question_text_last_update_trigger \u0434\u043b\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u044b info.isupoll_question_text.<\/p>\n<p><strong>\u0412\u0430\u0436\u043d\u043e!<\/strong> \u0412 \u0442\u0440\u0438\u0433\u0433\u0435\u0440\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e <strong>before, <\/strong>\u043a\u043e\u0433\u0434\u0430 \u0445\u043e\u0442\u0438\u0442\u0435 \u043d\u0430\u0448\u043a\u043e\u0434\u043d\u0438\u0447\u0430\u0442\u044c \u0432 \u0442\u043e\u0439 \u0436\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u0435, \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u0442\u0440\u0438\u0433\u0433\u0435\u0440, \u0438 <strong>after <\/strong>\u2014 \u0434\u043b\u044f \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0432 \u0434\u0440\u0443\u0433\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443.<\/p>\n<p>\u0411\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043f\u0440\u043e DML-\u0442\u0440\u0438\u0433\u0433\u0435\u0440\u044b:<\/p>\n<ol>\n<li>\n<p><a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/relational-databases\/triggers\/dml-triggers?view=sql-server-2017\"><u>MS SQL Server<\/u><\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/postgrespro.ru\/docs\/postgresql\/14\/triggers\"><u>PostgreSQL<\/u><\/a><\/p>\n<\/li>\n<\/ol>\n<p>\u0418 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0431\u043e\u043d\u0443\u0441\u0430 \u043a\u0440\u0430\u0442\u043a\u043e \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0439 \u0438 \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043c \u0441\u0441\u044b\u043b\u043a\u0438 \u0434\u043b\u044f \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430.<\/p>\n<h2>\u041d\u0435\u043c\u043d\u043e\u0433\u043e \u043e \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0439 \u0438 \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0435<\/h2>\n<p>\u0421\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0439<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td data-colwidth=\"234\" width=\"234\">\n<p><strong>MS SQL Server<\/strong><\/p>\n<\/td>\n<td data-colwidth=\"185\" width=\"185\">\n<p><strong>PostgreSQL<\/strong><\/p>\n<\/td>\n<td>\n<p><strong>\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"234\" width=\"234\">\n<p><a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/relational-databases\/system-information-schema-views\/system-information-schema-views-transact-sql?view=sql-server-ver15\"><u>\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u0445\u0435\u043c\u044b \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u0441\u0432\u0435\u0434\u0435\u043d\u0438\u0439<\/u><\/a><\/p>\n<\/td>\n<td data-colwidth=\"185\" width=\"185\">\n<p><a href=\"https:\/\/www.postgresql.org\/docs\/14\/views-overview.html\"><u>System Views<\/u><\/a><\/p>\n<\/td>\n<td>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"234\" width=\"234\">\n<p><a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/relational-databases\/system-dynamic-management-views\/sys-dm-exec-query-stats-transact-sql?view=sql-server-ver15\"><u>sys.dm_exec_query_stats<\/u><\/a><\/p>\n<\/td>\n<td data-colwidth=\"185\" width=\"185\">\n<p><a href=\"https:\/\/postgrespro.ru\/docs\/postgresql\/14\/pgstatstatements\"><u>pg_stat_statements<\/u><\/a><\/p>\n<\/td>\n<td>\n<p>\u041f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0443 \u043f\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u044b\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u043c.<\/p>\n<p>\u0412 MS SQL Server \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u043e, \u0447\u0442\u043e \u0432 \u043a\u0435\u0448\u0435, \u0430 \u0432 PostgreSQL \u2014 \u0432\u0441\u044e \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0443.<\/p>\n<p>\u0414\u043b\u044f PostgreSQL:<\/p>\n<p>CREATE EXTENSION pg_stat_statements;<\/p>\n<p>\u043d\u0430 \u043a\u0430\u0436\u0434\u0443\u044e \u0411\u0414.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"234\" width=\"234\">\n<p><a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/relational-databases\/system-dynamic-management-views\/sys-dm-exec-function-stats-transact-sql?view=sql-server-ver15\"><u>sys.dm_exec_function_stats<\/u><\/a><\/p>\n<\/td>\n<td data-colwidth=\"185\" width=\"185\">\n<p><a href=\"https:\/\/postgrespro.ru\/docs\/postgresql\/14\/monitoring-stats#MONITORING-PG-STAT-USER-FUNCTIONS-VIEW\"><u>pg_stat_user_functions<\/u><\/a><\/p>\n<\/td>\n<td>\n<p>\u041f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0443 \u043f\u043e \u0432\u044b\u0437\u043e\u0432\u0430\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"234\" width=\"234\">\n<p><a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/relational-databases\/system-dynamic-management-views\/sys-dm-db-index-usage-stats-transact-sql?view=sql-server-ver15\"><u>sys.dm_db_index_usage_stats<\/u><\/a><\/p>\n<\/td>\n<td data-colwidth=\"185\" width=\"185\">\n<p><a href=\"https:\/\/postgrespro.ru\/docs\/postgresql\/14\/monitoring-stats\"><u>pg_stat_all_indexes<\/u><\/a><\/p>\n<p><a href=\"https:\/\/postgrespro.ru\/docs\/postgresql\/14\/monitoring-stats\"><u>pg_stat_user_indexes<\/u><\/a><\/p>\n<\/td>\n<td>\n<p>\u041f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0443 \u043f\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044e \u0432\u0441\u0435\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0445 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"234\" width=\"234\">\n<p><a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/relational-databases\/system-catalog-views\/sys-master-files-transact-sql?view=sql-server-ver15\"><u>sys.master_files<\/u><\/a><\/p>\n<p><a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/relational-databases\/system-functions\/sys-fn-virtualfilestats-transact-sql?view=sql-server-ver15\"><u>sys.fn_virtualfilestats (NULL, NULL)<\/u><\/a><\/p>\n<\/td>\n<td data-colwidth=\"185\" width=\"185\">\n<p><a href=\"https:\/\/postgrespro.ru\/docs\/postgresql\/14\/monitoring-stats#MONITORING-PG-STAT-DATABASE-VIEW\"><u>pg_stat_database<\/u><\/a><\/p>\n<\/td>\n<td>\n<p>\u041f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e \u043a\u0430\u0436\u0434\u043e\u0439 \u0411\u0414.<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u0421\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f PostgreSQL:<br \/><a href=\"https:\/\/postgrespro.ru\/docs\/postgresql\/14\/monitoring-stats\"><u>\u0421\u0431\u043e\u0440\u0449\u0438\u043a \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0438<\/u><\/a><\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/6e8\/d50\/06b\/6e8d5006b0e2d0a234bf17bf9f925492.PNG\" alt=\"\" title=\"\" width=\"949\" height=\"707\"\/><figcaption><\/figcaption><\/figure>\n<p><em><sup>\u0418\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0432\u0437\u044f\u0442\u043e \u0441 <\/sup><\/em><a href=\"https:\/\/dataegret.ru\/2020\/10\/postgres-13-observability-updates\/\"><em><sup>Postgres 13 Observability Updates<\/sup><\/em><\/a><em><sup>.<\/sup><\/em><\/p>\n<p>\u0421\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f MS SQL Server:<\/p>\n<ol>\n<li>\n<p><a href=\"https:\/\/www.microsoft.com\/en-us\/download\/details.aspx?id=39083\"><u>SQL Server 2012 System Views Map<\/u><\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/relational-databases\/system-dynamic-management-views\/system-dynamic-management-views?view=sql-server-ver15\"><u>\u0421\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0435 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u0438\u0432\u043d\u044b\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f<\/u><\/a><\/p>\n<\/li>\n<\/ol>\n<h4>\u041c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433 \u0440\u0430\u0431\u043e\u0442\u044b \u0421\u0423\u0411\u0414<\/h4>\n<ul>\n<li>\n<p><a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/relational-databases\/performance\/monitor-and-tune-for-performance?view=sql-server-ver15\"><u>MS SQL Server<\/u><\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/postgrespro.ru\/docs\/postgresql\/13\/monitoring-stats\"><u>PostgreSQL<\/u><\/a><\/p>\n<\/li>\n<\/ul>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>\u041c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043b\u0438 \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0442\u0438\u043f\u043e\u0432 \u0438 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0430 MS SQL Server \u0438 PostgreSQL, \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u0430\u0434\u0430\u043f\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0438\u0437 \u043e\u0434\u043d\u043e\u0439 \u0421\u0423\u0411\u0414 \u043f\u043e\u0434 \u0434\u0440\u0443\u0433\u0443\u044e.<\/p>\n<p>\u0422\u0430\u043a\u0436\u0435 \u043c\u044b \u043f\u0440\u043e\u0431\u0435\u0436\u0430\u043b\u0438\u0441\u044c \u043f\u043e \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0439 \u0438 \u0441\u0441\u044b\u043b\u043a\u0430\u043c \u043d\u0430 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u043e \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0435, \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0438\u043b\u0438 \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0451\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430.<\/p>\n<h2>\u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u043d\u043e\u0441\u0442\u044c<\/h2>\n<p>\u0421\u043f\u0430\u0441\u0438\u0431\u043e \u043a\u043e\u043b\u043b\u0435\u0433\u0430\u043c \u0437\u0430 \u0446\u0435\u043d\u043d\u044b\u0435 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438:<\/p>\n<ul>\n<li>\n<p><a class=\"mention\" href=\"\/users\/kilor\">@Kilor<\/a><\/p>\n<\/li>\n<li>\n<p><a class=\"mention\" href=\"\/users\/vadv\">@vadv<\/a><\/p>\n<\/li>\n<li>\n<p><a class=\"mention\" href=\"\/users\/evilbloodydemon\">@evilbloodydemon<\/a><\/p>\n<\/li>\n<li>\n<p><a class=\"mention\" href=\"\/users\/unfilled\">@unfilled<\/a><\/p>\n<\/li>\n<li>\n<p><a class=\"mention\" href=\"\/users\/xek\">@XEK<\/a><\/p>\n<\/li>\n<li>\n<p><a class=\"mention\" href=\"\/users\/nikkolayy\">@Nikkolayy<\/a><\/p>\n<\/li>\n<\/ul>\n<h2>\u0418\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0438<\/h2>\n<ul>\n<li>\n<p><a href=\"https:\/\/pgconf.ru\/media\/2017\/04\/03\/20170317H1_Zhukovets_v.32.pdf\"><u>\u041c\u0438\u0433\u0440\u0430\u0446\u0438\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0433\u043e \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u00ab\u041f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u00bb \u0441 MS SQL Server \u043d\u0430 PostgreSQL<\/u><\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/sql-server\/?view=sql-server-ver15\"><u>MS SQL Server<\/u><\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/postgrespro.ru\/docs\/postgresql\/14\/index\"><u>PostgreSQL<\/u><\/a><\/p>\n<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/645173\/\"> https:\/\/habr.com\/ru\/articles\/645173\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u041f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e, \u0443\u0432\u0430\u0436\u0430\u0435\u043c\u044b\u0435 \u0445\u0430\u0431\u0440\u0430\u0436\u0438\u0442\u0435\u043b\u0438!<\/p>\n<p>\u042f \u0437\u0430\u043d\u0438\u043c\u0430\u044e\u0441\u044c \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u043e\u043c \u043a\u043e\u0434\u0430 \u0438\u0437 MS SQL Server \u0432 PostgreSQL \u0441 \u043d\u0430\u0447\u0430\u043b\u0430 2019 \u0433\u043e\u0434\u0430 \u0438 \u0441\u0435\u0433\u043e\u0434\u043d\u044f\u00a0 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0443 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u044d\u0442\u0438\u0445 \u0421\u0423\u0411\u0414.<\/p>\n<p>\u0412 <a href=\"https:\/\/habr.com\/ru\/post\/457602\/\"><u>\u043f\u0440\u043e\u0448\u043b\u043e\u0439 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438<\/u><\/a> \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u043b\u0438 \u043e\u0442\u043b\u0438\u0447\u0438\u044f \u0432 \u0431\u044b\u0441\u0442\u0440\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0438 MS SQL Server \u0438 PostgreSQL \u0434\u043b\u044f \u00ab1C\u00bb.<\/p>\n<p>\u0412 Ozon \u0435\u0441\u0442\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0438 \u043d\u0430 MS SQL Server, \u0438 \u043d\u0430 PostgreSQL: \u043f\u0435\u0440\u0432\u0430\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u043b\u043e\u0433\u0438\u0441\u0442\u0438\u043a\u0435 \u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0445 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0445 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432, \u0432\u0442\u043e\u0440\u0430\u044f \u2014 \u0432 mission critical-\u043f\u043e\u0434\u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0445, \u043e\u0442 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u0431\u0438\u0437\u043d\u0435\u0441 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 (\u0441\u043a\u043b\u0430\u0434, \u043a\u043e\u0440\u0437\u0438\u043d\u0430, \u043e\u043f\u043b\u0430\u0442\u0430 \u043a\u0430\u0440\u0442\u0430\u043c\u0438, \u043f\u043b\u0430\u0442\u0435\u0436\u0438, \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u0442\u043e\u0432\u0430\u0440\u0430\u0445 \u043d\u0430 \u0441\u0430\u0439\u0442\u0435 \u0438 \u0434\u0440.).<\/p>\n<p>\u041f\u0435\u0440\u0438\u043e\u0434\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u043e\u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0437\u0430\u0434\u0430\u0447\u0438 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0430 \u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u0438\u0437 \u043e\u0433\u0440\u043e\u043c\u043d\u044b\u0445 \u043c\u043e\u043d\u043e\u043b\u0438\u0442\u043d\u044b\u0445 \u0431\u0430\u0437 \u0438\u0437 MS SQL Server \u0432 PostgreSQL. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u0440\u0430\u0432\u043d\u0438\u043c \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0430 \u044d\u0442\u0438\u0445 \u0421\u0423\u0411\u0414 \u0434\u043b\u044f \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0433\u043e \u0447\u0442\u0435\u043d\u0438\u044f \u043a\u043e\u0434\u0430, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0431\u044b\u0441\u0442\u0440\u043e \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u043a\u043e\u0434 \u0438\u0437 MS SQL Server \u0434\u043b\u044f PostgreSQL \u0438 \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442.<\/p>\n<p>\u041d\u0430\u0447\u043d\u0451\u043c \u0441 \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0442\u0438\u043f\u043e\u0432.<\/p>\n<h2>\u0421\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0442\u0438\u043f\u043e\u0432<\/h2>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p>MS SQL<\/p>\n<\/td>\n<td>\n<p>PostgreSQL<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>BIGINT<\/p>\n<\/td>\n<td>\n<p>BIGINT, INT8<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>BINARY(n)<\/p>\n<\/td>\n<td>\n<p>BYTEA<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>VARBINARY(n)<\/p>\n<\/td>\n<td>\n<p>BYTEA<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>VARBINARY(max)<\/p>\n<\/td>\n<td>\n<p>BYTEA<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>ROWVERSION<\/p>\n<\/td>\n<td>\n<p>BYTEA<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>IMAGE<\/p>\n<\/td>\n<td>\n<p>BYTEA<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>FIELDHIERARCHYID<\/p>\n<\/td>\n<td>\n<p>BYTEA, LTREE (<a href=\"https:\/\/www.postgresql.org\/docs\/11\/ltree.html\"><u>\u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435<\/u><\/a>)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>BIT<\/p>\n<\/td>\n<td>\n<p>BOOLEAN, BOOL<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>CHAR(n), n&lt;=8000<\/p>\n<\/td>\n<td>\n<p>TEXT<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>NCHAR(n), n&lt;=4000<\/p>\n<\/td>\n<td>\n<p>TEXT<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>VARCHAR(n), n&lt;=8000<\/p>\n<\/td>\n<td>\n<p>TEXT<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>NVARCHAR(n), n&lt;=4000<\/p>\n<\/td>\n<td>\n<p>TEXT<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>VARCHAR(max)<\/p>\n<\/td>\n<td>\n<p>TEXT<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>NVARCHAR(max)<\/p>\n<\/td>\n<td>\n<p>TEXT<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>TEXT<\/p>\n<\/td>\n<td>\n<p>TEXT<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>NTEXT<\/p>\n<\/td>\n<td>\n<p>TEXT<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>FLOAT(n)<\/p>\n<\/td>\n<td>\n<p>DOUBLE PRECISION, FLOAT8<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>SMALLMONEY<\/p>\n<\/td>\n<td>\n<p>MONEY<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>MONEY<\/p>\n<\/td>\n<td>\n<p>MONEY<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>INT, INTEGER<\/p>\n<\/td>\n<td>\n<p>INT, INTEGER, INT4<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>SMALLINT<\/p>\n<\/td>\n<td>\n<p>SMALLINT, INT2<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>NUMERIC(n,m)<\/p>\n<\/td>\n<td>\n<p>NUMERIC(n,m)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>DEC(n,m), DECIMAL(n,m)<\/p>\n<\/td>\n<td>\n<p>DEC(n,m), DECIMAL(n,m)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>TINYINT<\/p>\n<\/td>\n<td>\n<p>SMALLINT, INT2<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>REAL<\/p>\n<\/td>\n<td>\n<p>REAL, FLOAT4<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>UNIQUEIDENTIFIER<\/p>\n<\/td>\n<td>\n<p>CHAR(16), UUID<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>DATE<\/p>\n<\/td>\n<td>\n<p>DATE<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>TIME(n)<\/p>\n<\/td>\n<td>\n<p>TIME(n)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>DATETIME<\/p>\n<\/td>\n<td>\n<p>TIMESTAMP(3)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>DATETIME2(n)<\/p>\n<\/td>\n<td>\n<p>TIMESTAMP(m)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>DATETIMEOFFSET(n)<\/p>\n<\/td>\n<td>\n<p>TIMESTAMP(n) WITH TIME ZONE, TIMESTAMPTZ<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>SMALLDATETIME<\/p>\n<\/td>\n<td>\n<p>TIMESTAMP(0)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>XML<\/p>\n<\/td>\n<td>\n<p>XML<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p><em>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435.<\/em> \u0422\u0438\u043f\u044b CHAR \u0438 VARCHAR \u043b\u0443\u0447\u0448\u0435 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c. \u041f\u0440\u0438\u0447\u0438\u043d\u044b \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u044b <a href=\"https:\/\/wiki.postgresql.org\/wiki\/Don%27t_Do_This\"><u>\u0437\u0434\u0435\u0441\u044c<\/u><\/a>.<\/p>\n<p>\u0411\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043e \u0442\u0438\u043f\u0430\u0445 \u0434\u0430\u043d\u043d\u044b\u0445:<\/p>\n<ol>\n<li>\n<p><a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/t-sql\/data-types\/data-types-transact-sql?view=sql-server-ver15\"><u>MS SQL Server<\/u><\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/postgrespro.ru\/docs\/postgresql\/12\/datatype\"><u>PostgreSQL<\/u><\/a><\/p>\n<\/li>\n<\/ol>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0435\u0440\u0435\u0439\u0434\u0451\u043c \u043a \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044e \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0430 MS SQL Server \u0438 PostgreSQL.<\/p>\n<h2>\u0421\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0430 MS SQL Server \u0438 PostgreSQL<\/h2>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p><strong>I. \u0420\u0435\u0433\u0438\u0441\u0442\u0440\u043e\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0435 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u043a \u0441\u0445\u0435\u043c\u0430\u043c, \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u043c (\u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f\u043c) \u0438 \u0438\u0445 \u043f\u043e\u043b\u044f\u043c \u0438 \u0434\u0440\u0443\u0433\u0438\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445<\/strong><\/p>\n<p>\u0412 MS SQL Server \u043f\u0440\u0438 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f\u0445 \u043a \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043d\u044b\u0435 \u0441\u043a\u043e\u0431\u043a\u0438 (\u043e\u043d\u0438 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b, \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0441\u043b\u0438 \u0432 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0438\u043b\u0438 \u0435\u0433\u043e \u043f\u043e\u043b\u044f \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u043d\u0435\u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u044b\u0435 \u0441\u0438\u043c\u0432\u043e\u043b\u044b):<\/p>\n<pre><code class=\"sql\">[schema] [table] [view] [object] [table].[field] [view].[field] [schema].[table] [schema].[view] [schema].[object] [schema].[table].[field] [schema].[view].[field]<\/code><\/pre>\n<p>\u0412 PostgreSQL \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0434\u0432\u043e\u0439\u043d\u044b\u0435 \u043a\u0430\u0432\u044b\u0447\u043a\u0438 (\u043e\u043d\u0438 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b, \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0441\u043b\u0438 \u0432 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u0437\u0430\u0433\u043b\u0430\u0432\u043d\u044b\u0435 \u0431\u0443\u043a\u0432\u044b \u0438\u043b\u0438 \u0435\u0441\u0442\u044c \u043d\u0435\u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u044b\u0435 \u0441\u0438\u043c\u0432\u043e\u043b\u044b \u0432 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0438\u043b\u0438 \u0435\u0433\u043e \u043f\u043e\u043b\u044f):<\/p>\n<pre><code class=\"sql\">\"schema\" \"table\" \"view\" \"table\".\"field\" \"view\".\"field\" \"schema\".\"table\" \"schema\".\"view\" \"schema\".\"table\".\"field\" \"schema\".\"view\".\"field\"<\/code><\/pre>\n<p><strong>II. \u0412\u044b\u0431\u043e\u0440\u043a\u0430 \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0445 N \u0434\u0430\u043d\u043d\u044b\u0445<\/strong><\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p>\u0412 MS SQL Server \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f <a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/t-sql\/queries\/top-transact-sql?view=sql-server-ver15\">TOP<\/a>:<\/p>\n<\/td>\n<td>\n<p>\u0412 PostgreSQL \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f <a href=\"https:\/\/postgrespro.ru\/docs\/postgresql\/14\/queries-limit\">LIMIT<\/a>:<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>SELECT TOP(N) &#8230;;<\/p>\n<\/td>\n<td>\n<p>SELECT &#8230;. LIMIT N;<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p><strong>III. \u041f\u043e\u0441\u0442\u0440\u0430\u043d\u0438\u0447\u043d\u0430\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 (\u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0435\u0435 \u043e\u043a\u043d\u043e)<\/strong><br \/>\u0417\u0430\u0434\u0430\u0447\u0430: \u0438\u0437\u0432\u043b\u0435\u0447\u044c 100 \u0441\u0442\u0440\u043e\u043a \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 202-\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u043e \u0432\u043e\u0437\u0440\u0430\u0441\u0442\u0430\u043d\u0438\u044e \u0434\u0430\u0442\u044b \u0440\u043e\u0436\u0434\u0435\u043d\u0438\u044f:<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td data-colwidth=\"334\" width=\"334\">\n<p>\u0432 <a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/t-sql\/queries\/select-order-by-clause-transact-sql?view=sql-server-ver15\">MS SQL Server<\/a>:<\/p>\n<\/td>\n<td>\n<p>\u0432 <a href=\"https:\/\/postgrespro.ru\/docs\/postgresql\/14\/sql-select\">PostgreSQL<\/a>:<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"334\" width=\"334\">\n<p>SELECT *<br \/>FROM tbl<br \/>ORDER BY BirthDate ASC<br \/>OFFSET 201 ROW FETCH<br \/>NEXT 100 ROWS ONLY;<\/p>\n<\/td>\n<td>\n<p>select *<br \/> from tbl<br \/> order by BirthDate asc<br \/> [&#8212;offset 201 row fetch<br \/> next 100 rows only;]<br \/> LIMIT 100 OFFSET 200<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td colspan=\"2\" data-colwidth=\"334,0\" width=\"334\">\n<p><em>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435.<\/em> \u0412\u043c\u0435\u0441\u0442\u043e row \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c rows \u0432 \u043b\u044e\u0431\u043e\u043c \u043c\u0435\u0441\u0442\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u0430 \u0432\u043c\u0435\u0441\u0442\u043e next \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c first \u0432 \u043e\u0431\u0435\u0438\u0445 \u0421\u0423\u0411\u0414.<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p><strong>IV. \u0412\u044b\u0431\u043e\u0440\u043a\u0430 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u043d\u0435\u043f\u0443\u0441\u0442\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f<\/strong><\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p>MS SQL Server<\/p>\n<\/td>\n<td>\n<p>PostgreSQL<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/t-sql\/language-elements\/coalesce-transact-sql?view=sql-server-ver15\"><u>COALESCE<\/u><\/a> \u2014 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u0442\u0441\u044f<\/p>\n<p><a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/t-sql\/functions\/isnull-transact-sql?view=sql-server-ver15\"><u>ISNULL<\/u><\/a> \u2014 \u043d\u0435 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u0442\u0441\u044f<\/p>\n<\/td>\n<td>\n<p><a href=\"https:\/\/postgrespro.ru\/docs\/postgresql\/14\/functions-conditional#FUNCTIONS-COALESCE-NVL-IFNULL\"><u>coalesce<\/u><\/a><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p><strong>V. \u0422\u0435\u0440\u043d\u0430\u0440\u043d\u044b\u0439 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 IIF<\/strong><\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td data-colwidth=\"337\" width=\"337\">\n<p>MS SQL Server<\/p>\n<\/td>\n<td>\n<p>PostgreSQL<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"337\" width=\"337\">\n<p><a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/t-sql\/functions\/logical-functions-iif-transact-sql?view=sql-server-ver15\"><u>IIF<\/u><\/a> (&lt;\u0443\u0441\u043b\u043e\u0432\u0438\u0435>,&lt;\u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435_\u0435\u0441\u043b\u0438_\u0443\u0441\u043b\u043e\u0432\u0438\u0435_\u0438\u0441\u0442\u0438\u043d\u043d\u043e>,&lt;\u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435_\u0435\u0441\u043b\u0438_\u0443\u0441\u043b\u043e\u0432\u0438\u0435_\u043b\u043e\u0436\u043d\u043e>)<\/p>\n<p>\u0438\u043b\u0438<\/p>\n<p><a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/t-sql\/language-elements\/case-transact-sql?view=sql-server-ver15\"><u>CASE<\/u><\/a> WHEN &lt;\u0443\u0441\u043b\u043e\u0432\u0438\u0435> THEN &lt;\u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435_\u0435\u0441\u043b\u0438_\u0443\u0441\u043b\u043e\u0432\u0438\u0435_\u0438\u0441\u0442\u0438\u043d\u043d\u043e> ELSE &lt;\u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435_\u0435\u0441\u043b\u0438_\u0443\u0441\u043b\u043e\u0432\u0438\u0435_\u043b\u043e\u0436\u043d\u043e> END<\/p>\n<\/td>\n<td>\n<p><a href=\"https:\/\/postgrespro.ru\/docs\/postgresql\/14\/functions-conditional#FUNCTIONS-CASE\"><u>case<\/u><\/a> when &lt;\u0443\u0441\u043b\u043e\u0432\u0438\u0435> then &lt;\u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435_\u0435\u0441\u043b\u0438_\u0443\u0441\u043b\u043e\u0432\u0438\u0435_\u0438\u0441\u0442\u0438\u043d\u043d\u043e> else &lt;\u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435_\u0435\u0441\u043b\u0438_\u0443\u0441\u043b\u043e\u0432\u0438\u0435_\u043b\u043e\u0436\u043d\u043e> end<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p><strong>VI. \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u0441\u0435\u0432\u0434\u043e\u043d\u0438\u043c\u0430<\/strong><\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p>MS SQL Server<\/p>\n<\/td>\n<td>\n<p>PostgreSQL<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>AS \u2014 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u0442\u0441\u044f<\/p>\n<p>= \u2014 \u043d\u0435 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u0442\u0441\u044f<\/p>\n<\/td>\n<td>\n<p>as<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p><strong>VII. \u0412\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f CASE<\/strong><\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p>MS SQL Server<\/p>\n<\/td>\n<td>\n<p>PostgreSQL<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/t-sql\/language-elements\/case-transact-sql?view=sql-server-ver15\">CASE<\/a>-WHEN-THEN-END<\/p>\n<p><a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/t-sql\/language-elements\/case-transact-sql?view=sql-server-ver15\">CASE<\/a>-WHEN-THEN-ELSE-END<\/p>\n<\/td>\n<td>\n<p><a href=\"https:\/\/postgrespro.ru\/docs\/postgresql\/14\/functions-conditional#FUNCTIONS-CASE\">case<\/a>-when-then-end<\/p>\n<p><a href=\"https:\/\/postgrespro.ru\/docs\/postgresql\/14\/functions-conditional#FUNCTIONS-CASE\">case<\/a>-when-then-else-end<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p><strong>VIII. \u0420\u0430\u0431\u043e\u0442\u0430 \u0441 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c\u0438<\/strong><\/p>\n<p><strong>\u041e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439<\/strong><\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p>MS SQL Server<\/p>\n<\/td>\n<td>\n<p>PostgreSQL<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>DECLARE @val;<\/p>\n<\/td>\n<td>\n<p>declare val;<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td colspan=\"2\">\n<p><em>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435.<\/em> \u0412 MS SQL Server \u043f\u0440\u0438 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0437\u043d\u0430\u043a @ \u043f\u0435\u0440\u0435\u0434 \u0438\u043c\u0435\u043d\u0435\u043c, \u0430 \u0432 PostgreSQL \u2014 \u043d\u0435\u0442. \u0422\u0430\u043a\u0436\u0435, \u043f\u043e\u043c\u0438\u043c\u043e <a href=\"https:\/\/github.com\/postgres\/postgres\/tree\/c30f54ad732ca5c8762bb68bbe0f51de9137dd72\/src\/pl\/plpgsql\"><u>PL\/pgSQL<\/u><\/a>, \u0432 PostgreSQL \u043c\u043e\u0436\u043d\u043e \u0432\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u044f\u0437\u044b\u043a\u0438, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a <a href=\"https:\/\/github.com\/postgres\/postgres\/tree\/c30f54ad732ca5c8762bb68bbe0f51de9137dd72\/src\/pl\/plpython\"><u>PL\/Python<\/u><\/a> \u0438 <a href=\"https:\/\/github.com\/postgres\/postgres\/tree\/c30f54ad732ca5c8762bb68bbe0f51de9137dd72\/src\/pl\/plperl\"><u>PL\/Perl<\/u><\/a>.<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p><strong>\u041f\u0440\u0438\u0441\u0432\u043e\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f<\/strong><\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p>MS SQL Server<\/p>\n<\/td>\n<td>\n<p>PostgreSQL<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>SET @\u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f = \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435;<\/p>\n<\/td>\n<td>\n<p>\u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f := \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td colspan=\"2\">\n<p><em>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435.<\/em> \u0412 PostgreSQL \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f := \u0434\u043b\u044f <a href=\"https:\/\/github.com\/postgres\/postgres\/tree\/c30f54ad732ca5c8762bb68bbe0f51de9137dd72\/src\/pl\/plpgsql\"><u>PL\/pgSQL<\/u><\/a> \u0438 \u043f\u0440\u043e\u0441\u0442\u043e = \u0434\u043b\u044f <a href=\"https:\/\/github.com\/postgres\/postgres\/tree\/c30f54ad732ca5c8762bb68bbe0f51de9137dd72\/src\/pl\/plpython\"><u>PL\/Python<\/u><\/a> \u0438 <a href=\"https:\/\/github.com\/postgres\/postgres\/tree\/c30f54ad732ca5c8762bb68bbe0f51de9137dd72\/src\/pl\/plperl\"><u>PL\/Perl<\/u><\/a>.<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p><strong>\u0412\u044b\u0432\u043e\u0434 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043d\u0430 \u043a\u043e\u043d\u0441\u043e\u043b\u044c<\/strong><\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p>MS SQL Server<\/p>\n<\/td>\n<td>\n<p>PostgreSQL<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>print &#8216;\u0441\u0442\u0440\u043e\u043a\u0430&#8217;;<\/p>\n<p>print @\u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f;<\/p>\n<p>RAISERROR(@\u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f, 1, 1) WITH NOWAIT;<\/p>\n<\/td>\n<td>\n<p>RAISE NOTICE &#8216;%&#8217;, &#8216;\u0441\u0442\u0440\u043e\u043a\u0430&#8217;;<\/p>\n<p>RAISE NOTICE &#8216;%&#8217;, &lt;\u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f>;<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p><strong>IX. \u0423\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435\u043c \u043a\u043e\u0434\u0430<\/strong><\/p>\n<p><strong>\u0412\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0441\u043a\u0440\u0438\u043f\u0442\u0430<\/strong><\/p>\n<p>\u0412 MS SQL Server:<\/p>\n<pre><code class=\"sql\">declare @_query int; set @_query=777; set @query=1+8; RAISERROR(@_query, 1, 1) WITH NOWAIT; --PRINT @_query;<\/code><\/pre>\n<p>\u0412 PostgreSQL:<\/p>\n<p>\u0428\u0430\u0431\u043b\u043e\u043d:<\/p>\n<pre><code class=\"sql\">do $$ &lt;\u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445>  begin &lt;\u043a\u043e\u0434>  end; $$;<\/code><\/pre>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 (\u0432\u044b\u0432\u043e\u0434 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438):<\/p>\n<pre><code class=\"sql\">do $$ declare _query int; begin _query:=777; _query:=1+8; RAISE NOTICE '%', _query; end; $$;<\/code><\/pre>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 (\u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043a\u043b\u0438\u0435\u043d\u0442\u0443):<\/p>\n<pre><code class=\"sql\">do $$ declare _query int; begin _query:=777; _query:=1+8; PERFORM set_config('my._query', _query::text, FALSE); end; $$; SELECT current_setting ('my._query');<\/code><\/pre>\n<p>\u0414\u043b\u044f PostgreSQL:<\/p>\n<ol>\n<li>\n<p>\u0412 DBeaver (\u0431\u043e\u0431\u0440\u0435) \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u0436\u0430\u0442\u044c CTRL+SHIFT+O \u043f\u0440\u0438 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0438 \u043e\u043a\u043d\u0430 \u0432\u044b\u0432\u043e\u0434\u0430, \u0430 \u0432 pgAdmin \u0432\u044b\u0432\u043e\u0434 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438.<\/p>\n<\/li>\n<li>\n<p>\u0412 psql \u0438 \u0442\u0430\u043a \u0432\u0441\u0451 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442.<\/p>\n<\/li>\n<\/ol>\n<p><strong>\u0426\u0438\u043a\u043b WHILE<\/strong><\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p>MS SQL Server<\/p>\n<\/td>\n<td>\n<p>PostgreSQL<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>WHILE &lt;\u0443\u0441\u043b\u043e\u0432\u0438\u0435_\u043f\u0440\u0438_\u043a\u043e\u0442\u043e\u0440\u043e\u043c_\u0446\u0438\u043a\u043b_\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442><\/p>\n<p>BEGIN<\/p>\n<p>&#8230;<\/p>\n<p>END<\/p>\n<\/td>\n<td>\n<p>while &lt;\u0443\u0441\u043b\u043e\u0432\u0438\u0435_\u043f\u0440\u0438_\u043a\u043e\u0442\u043e\u0440\u043e\u043c_\u0446\u0438\u043a\u043b_\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442><\/p>\n<p>loop<\/p>\n<p>&#8230;<\/p>\n<p>end loop<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p><strong>\u041b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0432\u0435\u0442\u0432\u043b\u0435\u043d\u0438\u0435<\/strong><\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p>MS SQL Server<\/p>\n<\/td>\n<td>\n<p>PostgreSQL<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>IF-BEGIN-END<\/p>\n<p>IF-BEGIN-END-ELSE-BEGIN-END<\/p>\n<\/td>\n<td>\n<p>if-then-else-end if;<\/p>\n<p>if-then-elseif-then-else-end if;<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u0411\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043f\u0440\u043e \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435\u043c \u043a\u043e\u0434\u0430:<\/p>\n<ol>\n<li>\n<p><a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/t-sql\/language-elements\/control-of-flow?view=sql-server-ver15\"><u>\u0423\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435\u043c \u043a\u043e\u0434\u0430 \u0432 MS SQL Server<\/u><\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/postgrespro.ru\/docs\/postgresql\/14\/plpgsql-control-structures\"><u>\u0423\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0432 PostgreSQL<\/u><\/a><\/p>\n<\/li>\n<\/ol>\n<p><strong>X. \u0424\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u043e \u0441\u0442\u0440\u043e\u043a\u0430\u043c\u0438<\/strong><\/p>\n<p><strong>\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0434\u043b\u0438\u043d\u044b \u0441\u0442\u0440\u043e\u043a\u0438 (\u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u0432 \u0441\u0442\u0440\u043e\u043a\u0435)<\/strong><\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p>MS SQL Server<\/p>\n<\/td>\n<td>\n<p>PostgreSQL<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/t-sql\/functions\/len-transact-sql?view=sql-server-ver15\"><u>LEN<\/u><\/a> (&lt;\u0441\u0442\u0440\u043e\u043a\u0430>)<\/p>\n<\/td>\n<td>\n<p><a href=\"https:\/\/postgrespro.ru\/docs\/postgresql\/14\/functions-string\"><u>length<\/u><\/a> (&lt;\u0441\u0442\u0440\u043e\u043a\u0430>)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td colspan=\"2\">\n<p><em>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435.<\/em> \u0412 MS SQL Server \u0438\u0441\u043a\u043b\u044e\u0447\u0430\u044e\u0442\u0441\u044f \u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0435 \u043f\u0440\u043e\u0431\u0435\u043b\u044b. \u0415\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u0438 \u0438\u0445, \u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 <a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/t-sql\/functions\/datalength-transact-sql?view=sql-server-ver15\"><u>DATALENGTH<\/u><\/a> (&lt;\u0441\u0442\u0440\u043e\u043a\u0430>), \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u0443\u043c\u043c\u0430\u0440\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0431\u0430\u0439\u0442\u043e\u0432 \u0432 \u0441\u0438\u043c\u0432\u043e\u043b\u0430\u0445 \u0441\u0442\u0440\u043e\u043a\u0438.<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p><strong>\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u0441\u0438\u043c\u0432\u043e\u043b\u0430 \u043f\u043e \u0435\u0433\u043e \u043a\u043e\u0434\u0443:<\/strong><\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p>MS SQL Server<\/p>\n<\/td>\n<td>\n<p>PostgreSQL<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>char(n)<\/p>\n<\/td>\n<td>\n<p>chr(n)<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p><strong>\u041a\u043e\u043d\u043a\u0430\u0442\u0435\u043d\u0430\u0446\u0438\u044f \u0441\u0442\u0440\u043e\u043a<\/strong><\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p>MS SQL Server<\/p>\n<\/td>\n<td>\n<p>PostgreSQL<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>+<\/p>\n<\/td>\n<td>\n<p>||<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p><strong>\u041d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u0432\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u043f\u043e\u0434\u0441\u0442\u0440\u043e\u043a\u0438<\/strong><\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p>\u0412 MS SQL Server:<\/p>\n<\/td>\n<td>\n<p>\u0412 PostgreSQL:<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>CHARINDEX(&lt;\u0447\u0442\u043e_\u0438\u0449\u0435\u043c>, &lt;\u0433\u0434\u0435_\u0438\u0449\u0435\u043c>,&lt;\u0441_\u043a\u0430\u043a\u043e\u0439_\u043f\u043e\u0437\u0438\u0446\u0438\u0438_\u0438\u0449\u0435\u043c_\u043d\u0430\u0447\u0438\u043d\u0430\u044f_\u0441_1>)<\/p>\n<\/td>\n<td>\n<p>strpos(&lt;\u0433\u0434\u0435_\u0438\u0449\u0435\u043c>, &lt;\u0447\u0442\u043e_\u0438\u0449\u0435\u043c>)<\/p>\n<p>strpos(substring(&lt;\u0433\u0434\u0435_\u0438\u0449\u0435\u043c>, &lt;\u0441_\u043a\u0430\u043a\u043e\u0439_\u043f\u043e\u0437\u0438\u0446\u0438\u0438_\u0438\u0449\u0435\u043c_\u043d\u0430\u0447\u0438\u043d\u0430\u044f_\u0441_1>, length(&lt;\u0433\u0434\u0435_\u0438\u0449\u0435\u043c>)- &lt;\u0441_\u043a\u0430\u043a\u043e\u0439_\u043f\u043e\u0437\u0438\u0446\u0438\u0438_\u0438\u0449\u0435\u043c_\u043d\u0430\u0447\u0438\u043d\u0430\u044f_\u0441_1>+1), &lt;\u0447\u0442\u043e_\u0438\u0449\u0435\u043c>)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td colspan=\"2\">\n<p><em>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435.<\/em> \u0422\u043e\u0447\u043d\u043e\u0433\u043e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u044f \u043d\u0435 \u0431\u0443\u0434\u0435\u0442, \u0435\u0441\u043b\u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u044c \u043f\u043e\u0438\u0441\u043a \u043d\u0435 \u0441 \u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u0442\u0440\u043e\u043a\u0438.<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p><strong>\u0420\u0435\u0433\u0438\u0441\u0442\u0440\u043e\u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0435 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0438 \u043f\u043e\u0438\u0441\u043a \u0434\u0430\u043d\u043d\u044b\u0445<\/strong><\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td data-colwidth=\"206\" width=\"206\">\n<p>\u0412 MS SQL Server:<\/p>\n<\/td>\n<td>\n<p>\u0412 PostgreSQL:<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"206\" width=\"206\">\n<p>1. LIKE<\/p>\n<p>2. a = b<\/p>\n<p>3. &lt;><\/p>\n<p>4. a in (b1, &#8230;)<\/p>\n<\/td>\n<td>\n<p>1. ilike<\/p>\n<p>2. lower(a) = lower(b) \u0438\u043b\u0438 upper(a)=upper(b)<\/p>\n<p>3. lower(a) &lt;> lower(b) \u0438\u043b\u0438 upper(a)&lt;>upper(b)<\/p>\n<p>4. lower(a) in (lower(b1), &#8230;) \u0438\u043b\u0438 upper(a) in (upper(b1), &#8230;)<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p><em>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435.<\/em> \u0412 PostgreSQL \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0441\u0442\u0438 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044e \u0447\u0435\u0440\u0435\u0437 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430:<\/p>\n<pre><code class=\"sql\">create [concurrently] index idx_lower_&lt;field>  on &lt;schema>.&lt;table> (lower(&lt;field>));  --\u041f\u043e\u0441\u043b\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f concurrently-\u0438\u043d\u0434\u0435\u043a\u0441\u0430,  --\u0435\u0433\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u043d\u0430 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0431\u0438\u0442\u044b\u0445 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c: SELECT indexrelid::regclass FROM pg_index where not indisvalid;  --\u0414\u0430\u043b\u0435\u0435 \u0434\u043b\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0438 \u043f\u043e \u043d\u0443\u0436\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435  --\u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 ANALYZE: ANALYZE &lt;table>;<\/code><\/pre>\n<p>\u0411\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043f\u0440\u043e \u043a\u043e\u043c\u0430\u043d\u0434\u0443 <a href=\"https:\/\/postgrespro.ru\/docs\/postgresql\/14\/sql-analyze\"><u>ANALYZE<\/u><\/a>.<\/p>\n<p><strong>\u0421\u043b\u0438\u044f\u043d\u0438\u0435 \u0441\u0442\u0440\u043e\u043a \u043f\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0443 \u0432 \u043e\u0434\u043d\u0443 \u0441\u0442\u0440\u043e\u043a\u0443 \u043f\u043e \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u043c\u0443 \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044e<\/strong><\/p>\n<p>\u0412 MS SQL Server \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/t-sql\/functions\/stuff-transact-sql?view=sql-server-ver15\"><u>STUFF<\/u><\/a> \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"sql\">STUFF(( SELECT DISTINCT                  ', ' + CONVERT(varchar, tbl.&lt;\u043f\u043e\u043b\u0435>)           FROM             &lt;\u0441\u0445\u0435\u043c\u0430>.&lt;\u0442\u0430\u0431\u043b\u0438\u0446\u0430> tbl           [WHERE             &lt;\u0443\u0441\u043b\u043e\u0432\u0438\u044f>]           FOR XML PATH(''))       , 1       , 1       , '') AS STUFF_tbl;<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0436\u0435 \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 \u0432\u0435\u0440\u0441\u0438\u0438 2017 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f <a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/t-sql\/functions\/string-agg-transact-sql?view=sql-server-ver15\"><u>STRING_AGG<\/u><\/a>.<\/p>\n<p>\u0412 PostgreSQL \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <a href=\"https:\/\/www.postgresqltutorial.com\/postgresql-aggregate-functions\/postgresql-string_agg-function\/\"><u>string_agg<\/u><\/a> \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"sql\">string_agg((SELECT distinct ', ' || cast(tbl.&lt;\u043f\u043e\u043b\u0435> as VARCHAR) FROM &lt;\u0441\u0445\u0435\u043c\u0430>.&lt;\u0442\u0430\u0431\u043b\u0438\u0446\u0430> tbl, [WHERE &lt;\u0443\u0441\u043b\u043e\u0432\u0438\u044f>] ), 1, 1, '') AS string_agg_field;<\/code><\/pre>\n<p>\u0411\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043f\u0440\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u043e \u0441\u0442\u0440\u043e\u043a\u0430\u043c\u0438:<\/p>\n<ol>\n<li>\n<p><a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/t-sql\/functions\/string-functions-transact-sql?view=sql-server-ver15\"><u>MS SQL Server<\/u><\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/postgrespro.ru\/docs\/postgresql\/14\/functions-string\"><u>PostgreSQL<\/u><\/a><\/p>\n<\/li>\n<\/ol>\n<p><strong>XI. \u0424\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0434\u0430\u0442\u043e\u0439 \u0438 \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c<\/strong><\/p>\n<p><strong>\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0434\u0430\u0442\u044b \u0438 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 (\u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f)<\/strong><\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p>MS SQL Server<\/p>\n<\/td>\n<td>\n<p>PostgreSQL<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>GetDate()<\/p>\n<p>SysDateTime()<\/p>\n<p>current_timestamp<\/p>\n<\/td>\n<td>\n<p>clock_timestamp<\/p>\n<p>now()<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p><strong>\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0434\u0430\u0442\u044b<\/strong><\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p>MS SQL Server<\/p>\n<\/td>\n<td>\n<p>PostgreSQL<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>CAST(GetDate() as DATE)<\/p>\n<\/td>\n<td>\n<p>current_date<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0444\u043e\u0440\u043c\u0430\u0442\u0430 \u0434\u0430\u0442\u044b \u0438 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0438\u0437 \u0441\u0442\u0440\u043e\u043a\u0438 public_date:<\/p>\n<p>\u0412 MS SQL Server:<\/p>\n<pre><code class=\"sql\">FORMAT(public_date, 'dd.MM.yyyy HH:mm:ss', 'ru-RU') \u2014 \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0442\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431  convert(varchar(32),convert(datetime,public_date,104),120)<\/code><\/pre>\n<p>\u0412 PostgreSQL:<\/p>\n<pre><code class=\"sql\">to_char(to_timestamp(public_date, 'dd.MM.yyyy hh24.mi'), 'yyyy-mm-dd hh24:mi:ss')<\/code><\/pre>\n<p><strong>\u041f\u0440\u0438\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u0434\u0430\u0442\u044b\/\u0432\u0440\u0435\u043c\u0435\u043d\u0438<\/strong><\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td data-colwidth=\"335\" width=\"335\">\n<p>\u0412 MS SQL Server:<\/p>\n<\/td>\n<td>\n<p>\u0412 PostgreSQL:<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"335\" width=\"335\">\n<p>DateAdd(datepart, count, dt);<\/p>\n<\/td>\n<td>\n<p>dt + (count * interval &#8216;1 datepart&#8217;);<br \/>\u0438\u043b\u0438<br \/>dt + interval &#8216;count datepart&#8217;;<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td colspan=\"2\" data-colwidth=\"335,0\" width=\"335\">\n<p>\u0411\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043f\u0440\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0434\u0430\u0442\u043e\u0439 \u0438 \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c: <\/p>\n<p>1. <a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/t-sql\/functions\/date-and-time-data-types-and-functions-transact-sql?view=sql-server-ver15\"><u>MS SQL Server<\/u><\/a><\/p>\n<p>2. <a href=\"https:\/\/postgrespro.ru\/docs\/postgresql\/14\/functions-datetime\"><u>PostgreSQL<\/u><\/a><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p><strong>XII. \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0441\u0442\u0440\u043e\u043a, \u0437\u0430\u0442\u0440\u043e\u043d\u0443\u0442\u044b\u0445 \u043f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u044b<\/strong><\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p>MS SQL Server<\/p>\n<\/td>\n<td>\n<p>PostgreSQL<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/t-sql\/functions\/rowcount-transact-sql?view=sql-server-ver15\"><u>@@ROWCOUNT<\/u><\/a><\/p>\n<\/td>\n<td>\n<p><a href=\"https:\/\/postgrespro.ru\/docs\/postgresql\/14\/plpgsql-statements\"><u>get diagnostics<\/u><\/a> &lt;\u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f>:=row_count;<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p><strong>XIII. \u0412\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e SQL-\u043a\u043e\u0434\u0430<\/strong><\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p>MS SQL Server<\/p>\n<\/td>\n<td>\n<p>PostgreSQL<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>execute <a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/relational-databases\/system-stored-procedures\/sp-executesql-transact-sql?view=sql-server-ver15\"><u>sp_executesql<\/u><\/a> @sql;<\/p>\n<\/td>\n<td>\n<p><a href=\"https:\/\/postgrespro.ru\/docs\/postgresql\/14\/sql-execute\"><u>execute<\/u><\/a> _sql;<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p><strong>XIV. \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0438 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0442\u0438\u043f\u043e\u0432<\/strong><\/p>\n<p><strong>\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0441\u0442\u0440\u043e\u043a\u0438 \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u043e\u043d\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0447\u0438\u0441\u043b\u043e\u043c<\/strong><\/p>\n<p>\u0412 MS SQL Server:<\/p>\n<p>\u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f <a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/t-sql\/functions\/isnumeric-transact-sql?view=sql-server-ver15\"><u>isnumeric<\/u><\/a>(val)<\/p>\n<p>\u0412 PostgreSQL:<\/p>\n<pre><code class=\"sql\">CREATE OR REPLACE FUNCTION dbo.isnumeric(_input varchar(255) DEFAULT NULL::varchar(255)) RETURNS bit LANGUAGE plpgsql AS $function$ \/* \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438 \u0432\u0445\u043e\u0434\u043d\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0447\u0438\u0441\u043b\u043e\u043c *\/ declare _result bit; begin begin perform _input::numeric; _result:=1::bit; exception when others THEN _result:=0::bit; end; return _result; end; $function$ ;<\/code><\/pre>\n<p><strong>\u0411\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0442\u0438\u043f\u0430<\/strong><\/p>\n<p>\u0412 MS SQL Server:<\/p>\n<pre><code class=\"sql\">try_cast(val as &lt;type>)<\/code><\/pre>\n<p><em>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435.<\/em> try_cast \u0432 MS SQL Server \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 NULL, \u0435\u0441\u043b\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u043c\u0443 \u0442\u0438\u043f\u0443, \u0432 \u0434\u0440\u0443\u0433\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u2014 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043a\u0430\u043a \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 CAST.<\/p>\n<p>\u0412 PostgreSQL \u0435\u0441\u0442\u044c \u0434\u0432\u0430 \u0441\u043f\u043e\u0441\u043e\u0431\u0430:<\/p>\n<p>1) \u0447\u0435\u0440\u0435\u0437 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u043e\u0448\u0438\u0431\u043e\u043a:<\/p>\n<pre><code class=\"sql\">declare _result \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 CAST &lt;type>; ...  BEGIN _result := cast(val as &lt;type>);  exception  when others then  _result :=null; end;<\/code><\/pre>\n<p>2) \u0447\u0435\u0440\u0435\u0437 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0438:<\/p>\n<pre><code class=\"sql\">CREATE OR<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-407040","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/407040","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=407040"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/407040\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=407040"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=407040"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=407040"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}