{"id":1723,"date":"2019-03-05T18:34:12","date_gmt":"2019-03-05T15:34:12","guid":{"rendered":"http:\/\/surgery.moscow\/smos\/?p=1723"},"modified":"2020-05-27T16:43:55","modified_gmt":"2020-05-27T13:43:55","slug":"mysql-mssql","status":"publish","type":"post","link":"https:\/\/surgery.moscow\/smos\/2019\/03\/05\/mysql-mssql\/","title":{"rendered":"Mysql   MSSQL SQL"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><strong>CREATE USER &#8216;name_user&#8217;@&#8217;host_name&#8217; IDENTIFIED BY &#8216;password&#8217;;<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u043a\u043e\u043d\u0432\u0435\u0440\u0441\u0438\u044f \u0442\u0430\u0431\u043b\u0438\u0446 \u0432 \u043d\u0443\u0436\u043d\u0443\u044e \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u043a\u0443<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>ALTER TABLE database_name CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_c<\/strong>i;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u043a\u0430\u043a \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0442\u0430\u0431\u043b\u0438\u0446 \u0438 \u0438\u0445 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0432 MySQL    <\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>SHOW DATABASES;<\/strong> &#8212; \u0441\u043f\u0438\u0441\u043e\u043a \u0431\u0430\u0437 \u0434\u0430\u043d\u043d\u044b\u0445<br><strong> SHOW TABLES [FROM db_name];<\/strong> &#8212;  \u0441\u043f\u0438\u0441\u043e\u043a \u0442\u0430\u0431\u043b\u0438\u0446 \u0432 \u0431\u0430\u0437\u0435 <br> <strong>SHOW COLUMNS FROM \u0442\u0430\u0431\u043b\u0438\u0446\u0430 [FROM db_name];<\/strong> &#8212; \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435<br><strong> SHOW CREATE TABLE table_name;<\/strong> &#8212; \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 &#171;CREATE TABLE&#187;<br><strong> SHOW INDEX FROM tbl_name;<\/strong> &#8212; \u0441\u043f\u0438\u0441\u043e\u043a \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432<br> <strong>SHOW GRANTS FOR user [FROM db_name];<\/strong> &#8212; \u043f\u0440\u0438\u0432\u0438\u043b\u0435\u0433\u0438\u0438 \u0434\u043b\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>SHOW VARIABLES; <\/strong>&#8212; \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445<br><strong>SHOW [FULL] PROCESSLIST; <\/strong>&#8212; \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0430 \u043f\u043e mysqld \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430\u043c<br><strong>SHOW STATUS;<\/strong> &#8212; \u043e\u0431\u0449\u0430\u044f \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0430<br><strong>SHOW TABLE STATUS [FROM db_name];<\/strong> &#8212; \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0430 \u043f\u043e \u0432\u0441\u0435\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u043c \u0432 \u0431\u0430\u0437\u0435<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u0414\u043e\u0431\u0430\u0432\u0438\u043b\u0435\u043d\u0438\u0435 \u043f\u0440\u0438\u0432\u0438\u043b\u0435\u0433\u0438\u0439 \u0434\u043b\u044f \u0442\u0430\u0431\u043b\u0438\u0446 \u0411\u0414 dbname \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e &#8216;user&#8217;@&#8217;localhost&#8217;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>mysql&gt; GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,ALTER,INDEX <br> ON dbname.* TO &#8216;user&#8217;@&#8217;localhost&#8217;;<\/strong><br>\u0438\u043b\u0438<br><strong>GRANT ALL PRIVILEGES ON db_name.* TO &#8216;user&#8217;@&#8217;host&#8217; WITH GRANT OPTION;<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u041a\u043e\u043d\u043a\u0430\u0442\u0435\u043d\u0430\u0446\u0438\u044f \u0441\u0442\u0440\u043e\u043a <br><br><strong>UPDATE <\/strong><code><code><code><code><strong> '<\/strong>\u0438\u043c\u044f_\u0441\u0442\u043e\u043b\u0431\u0446\u0430<strong>' <\/strong><code><code><strong>SET <\/strong><\/code><\/code><\/code><strong> '<\/strong>\u0438\u043c\u044f_\u043f\u043e\u043b\u044f<strong>'<\/strong><code><strong>= CONCAT('<\/strong>\u0444\u0440\u0430\u0437\u0430_\u043a\u043e\u0442\u043e\u0440\u0443\u044e_\u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c<strong> ', <\/strong><\/code><\/code><\/code><\/code><strong>&#8216;<\/strong>\u0438\u043c\u044f_\u043f\u043e\u043b\u044f<strong>&#8216;);<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u0417\u0430\u043c\u0435\u043d\u0430 \u0447\u0430\u0441\u0442\u0438 \u0441\u0442\u0440\u043e\u043a\u0438 <br><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">SQL \u043a\u0430\u043a \u0441\u0442\u0440\u043e\u043a\u0430 ABC \u0432 \u0441\u0442\u0440\u043e\u043a\u0435 ABCdefghi \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u043d\u0430 YYY.<br> <\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><br><strong> SELECT  table_name  REPLACE(&#8216;ABCefghicde&#8217;,&#8217;ABC&#8217;,&#8217;YYY&#8217;);  <br> GO  <\/strong><br> \u041d\u0438\u0436\u0435 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \u043d\u0430\u0431\u043e\u0440.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">YYYdefghi  <br>   <\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435  https:\/\/docs.microsoft.com\/ru-RU\/sql\/t-sql\/functions\/replace-transact-sql?view=aps-pdw-2016<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"> MySQL create database with UTF8 character set syntax, so here it is:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>CREATE DATABASE `mydb` CHARACTER SET utf8 COLLATE utf8_general_ci;\nGRANT ALL ON `mydb`.* TO `username`@localhost IDENTIFIED BY 'password';<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Alternatively, you can use &#8216;CREATE SCHEMA&#8217; instead of &#8216;CREATE DATABASE&#8217;:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>CREATE SCHEMA `mydb` CHARACTER SET utf8 COLLATE utf8_general_ci;\nGRANT ALL ON `mydb`.* TO `username`@localhost IDENTIFIED BY 'password';<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><br><strong>INSERT INTO<\/strong> Products (Name, SKU, Desc) <strong>VALUES<\/strong> (\u2018Protack\u2019, \u2018174006\u2019, &#8216;Hernia stapler&#8217;);<br><\/p>\n","protected":false},"excerpt":{"rendered":"<p>CREATE USER &#8216;name_user&#8217;@&#8217;host_name&#8217; IDENTIFIED BY &#8216;password&#8217;; \u043a\u043e\u043d\u0432\u0435\u0440\u0441\u0438\u044f \u0442\u0430\u0431\u043b\u0438\u0446 \u0432 \u043d\u0443\u0436\u043d\u0443\u044e \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u043a\u0443 ALTER TABLE database_name CONVERT TO CHARACTER SET utf8 COLLATE<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,12,22],"tags":[],"class_list":["post-1723","post","type-post","status-publish","format-standard","hentry","category-computer","category-internet","category-technology"],"_links":{"self":[{"href":"https:\/\/surgery.moscow\/smos\/wp-json\/wp\/v2\/posts\/1723","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/surgery.moscow\/smos\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/surgery.moscow\/smos\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/surgery.moscow\/smos\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/surgery.moscow\/smos\/wp-json\/wp\/v2\/comments?post=1723"}],"version-history":[{"count":12,"href":"https:\/\/surgery.moscow\/smos\/wp-json\/wp\/v2\/posts\/1723\/revisions"}],"predecessor-version":[{"id":2886,"href":"https:\/\/surgery.moscow\/smos\/wp-json\/wp\/v2\/posts\/1723\/revisions\/2886"}],"wp:attachment":[{"href":"https:\/\/surgery.moscow\/smos\/wp-json\/wp\/v2\/media?parent=1723"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/surgery.moscow\/smos\/wp-json\/wp\/v2\/categories?post=1723"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/surgery.moscow\/smos\/wp-json\/wp\/v2\/tags?post=1723"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}