{"id":1125,"date":"2024-12-10T02:38:22","date_gmt":"2024-12-10T08:38:22","guid":{"rendered":"https:\/\/thecweb.com\/?p=1125"},"modified":"2024-12-10T03:31:54","modified_gmt":"2024-12-10T09:31:54","slug":"sql-notes","status":"publish","type":"post","link":"https:\/\/thecweb.com\/index.php\/2024\/12\/10\/sql-notes\/","title":{"rendered":"SQL &#8211; notes"},"content":{"rendered":"\n<p>create user<\/p>\n\n\n\n<p><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>CREATE USER '&lt;username>'@'&lt;connect from hostname>' IDENTIFIED BY '&lt;password>';<\/code><\/pre>\n\n\n\n<p>grant access<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># basic syntax\nCREATE USER '&lt;username>'@'&lt;connect from hostname>' IDENTIFIED BY '&lt;password>';\n\n# as close to root without being root\n# probably shouldn't be giving any user this much access\nGRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES, RELOAD on *.* TO '&lt;username>'@'&lt;connect from hostname>' WITH GRANT OPTION;<\/code><\/pre>\n\n\n\n<p>database<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>create database &lt;databasename>;\n\nshow databases;<\/code><\/pre>\n\n\n\n<p>Inserting data<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># INSERT INTO Syntax\n# It is possible to write the INSERT INTO statement in two ways:\n# 1. Specify both the column names and the values to be inserted:\n\nINSERT INTO table_name (column1, column2, column3, ...)\nVALUES (value1, value2, value3, ...);\n\n# 2. If you are adding values for all the columns of the table, you do not need to specify the column names in the SQL query. However, make sure the order of the values is in the same order as the columns in the table. Here, the # INSERT INTO syntax would be as follows:\n\nINSERT INTO table_name\nVALUES (value1, value2, value3, ...);<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>create user grant access database Inserting data<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[48,47],"class_list":["post-1125","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-mysql","tag-sql"],"_links":{"self":[{"href":"https:\/\/thecweb.com\/index.php\/wp-json\/wp\/v2\/posts\/1125","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/thecweb.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/thecweb.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/thecweb.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/thecweb.com\/index.php\/wp-json\/wp\/v2\/comments?post=1125"}],"version-history":[{"count":4,"href":"https:\/\/thecweb.com\/index.php\/wp-json\/wp\/v2\/posts\/1125\/revisions"}],"predecessor-version":[{"id":1129,"href":"https:\/\/thecweb.com\/index.php\/wp-json\/wp\/v2\/posts\/1125\/revisions\/1129"}],"wp:attachment":[{"href":"https:\/\/thecweb.com\/index.php\/wp-json\/wp\/v2\/media?parent=1125"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/thecweb.com\/index.php\/wp-json\/wp\/v2\/categories?post=1125"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/thecweb.com\/index.php\/wp-json\/wp\/v2\/tags?post=1125"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}