{"id":46,"date":"2021-03-19T12:50:17","date_gmt":"2021-03-19T12:50:17","guid":{"rendered":"https:\/\/blogs.glowscotland.org.uk\/sh\/ahscomputingsql\/?page_id=46"},"modified":"2021-11-17T15:58:43","modified_gmt":"2021-11-17T15:58:43","slug":"data-types","status":"publish","type":"page","link":"https:\/\/blogs.glowscotland.org.uk\/sh\/ahscomputingsql\/reference\/data-types\/","title":{"rendered":"Data Types"},"content":{"rendered":"<h1>National 5 and Higher<\/h1>\n<h2>Text<\/h2>\n<p>Text values are enclosed in apostrophes (or quotation marks):<\/p>\n<pre class=\"brush: sql; title: ; notranslate\" title=\"\">\r\nSELECT * FROM orders\r\nWHERE productname LIKE 'Marzipan'\r\n<\/pre>\n<h2>Number<\/h2>\n<pre class=\"brush: sql; title: ; notranslate\" title=\"\">\r\nSELECT * FROM orders\r\nWHERE price &gt; 14.95\r\n<\/pre>\n<h2>Date<\/h2>\n<p>SQLite stores dates as text fields. They must be stored as &#8216;yyyy-mm-dd&#8217; eg &#8216;2021-03-05&#8217;<\/p>\n<pre class=\"brush: sql; title: ; notranslate\" title=\"\">\r\nSELECT * FROM orders\r\nWHERE date &lt;= '2020-03-28'\r\n<\/pre>\n<h2>Time<\/h2>\n<p>SQLite stores times as text fields. They must be stored as &#8216;hh:mm:ss&#8217;<\/p>\n<pre class=\"brush: sql; title: ; notranslate\" title=\"\">\r\nSELECT * FROM orders\r\nWHERE time BETWEEN '09:00:00' AND '09:59:59'\r\n<\/pre>\n<h2>Boolean<\/h2>\n<p>SQLite stores Boolean values as numbers &#8211; 1 for True and 0 for False<\/p>\n<pre class=\"brush: sql; title: ; notranslate\" title=\"\">\r\nSELECT * FROM orders\r\nWHERE delivered = 1\r\n<\/pre>\n<h1>Advanced Higher<\/h1>\n<p>In Advanced Higher you must use standard SQL types:<\/p>\n<table class=\"datatable\">\n<tbody>\n<tr>\n<td><strong>Data Type<\/strong><\/td>\n<td><strong>Sample<\/strong><\/td>\n<td><strong>SQL<\/strong><br \/>\n<strong>implementation<\/strong><\/td>\n<td><strong>Comment<\/strong><\/td>\n<\/tr>\n<tr>\n<td>integer<\/td>\n<td>32, -46<\/td>\n<td>\n<pre>int<\/pre>\n<\/td>\n<td>using a size parameter is optional; it is used to restrict the maximum display width<\/td>\n<\/tr>\n<tr>\n<td>float<\/td>\n<td>3.14<\/td>\n<td>\n<pre>float(size,d)<\/pre>\n<\/td>\n<td>the size parameter specifies the total number of digits displayed, while d specifies the number of digits after the decimal point<\/td>\n<\/tr>\n<tr>\n<td>varchar<\/td>\n<td>ABC123D<\/td>\n<td>\n<pre>varchar(size)<\/pre>\n<\/td>\n<td>the size parameter is mandatory, to restrict number of characters possible between 0 and 65535<\/td>\n<\/tr>\n<tr>\n<td>date<\/td>\n<td>2019-05-23<\/td>\n<td>\n<pre>date<\/pre>\n<\/td>\n<td>format is YYYY-MM-DD<\/td>\n<\/tr>\n<tr>\n<td>time<\/td>\n<td>09:12:47<\/td>\n<td>\n<pre>time<\/pre>\n<\/td>\n<td>format is YYYY-MM-DD<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>Primary and Keys&lt;\/<\/h2>\n","protected":false},"excerpt":{"rendered":"<p>National 5 and Higher Text Text values are enclosed in apostrophes (or quotation marks): SELECT * FROM orders WHERE productname LIKE &#8216;Marzipan&#8217; Number SELECT * FROM orders WHERE price &gt; 14.95 Date SQLite stores dates as text fields. They must be stored as &#8216;yyyy-mm-dd&#8217; eg &#8216;2021-03-05&#8217; SELECT * FROM orders WHERE date &lt;= &#8216;2020-03-28&#8242; Time SQLite stores times as text fields. They must be stored as &#8216;hh:mm:ss&#8217; SELECT * FROM<\/p>\n<p><a class=\"more-link\" href=\"https:\/\/blogs.glowscotland.org.uk\/sh\/ahscomputingsql\/reference\/data-types\/\">Read More<\/a><\/p>\n","protected":false},"author":7,"featured_media":0,"parent":53,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-46","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/blogs.glowscotland.org.uk\/sh\/ahscomputingsql\/wp-json\/wp\/v2\/pages\/46","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.glowscotland.org.uk\/sh\/ahscomputingsql\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/blogs.glowscotland.org.uk\/sh\/ahscomputingsql\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.glowscotland.org.uk\/sh\/ahscomputingsql\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.glowscotland.org.uk\/sh\/ahscomputingsql\/wp-json\/wp\/v2\/comments?post=46"}],"version-history":[{"count":8,"href":"https:\/\/blogs.glowscotland.org.uk\/sh\/ahscomputingsql\/wp-json\/wp\/v2\/pages\/46\/revisions"}],"predecessor-version":[{"id":617,"href":"https:\/\/blogs.glowscotland.org.uk\/sh\/ahscomputingsql\/wp-json\/wp\/v2\/pages\/46\/revisions\/617"}],"up":[{"embeddable":true,"href":"https:\/\/blogs.glowscotland.org.uk\/sh\/ahscomputingsql\/wp-json\/wp\/v2\/pages\/53"}],"wp:attachment":[{"href":"https:\/\/blogs.glowscotland.org.uk\/sh\/ahscomputingsql\/wp-json\/wp\/v2\/media?parent=46"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}