Базы данных, осень 2016: Краткое введение в базы данных и SQL программирование

  • Published on
    16-Jan-2017

  • View
    211

  • Download
    4

Embed Size (px)

Transcript

<ul><li><p> SQL</p><p> 13 2016 .</p><p>Computer Science Center</p></li><li><p>Creative CommonsAttribution - Share Alike 3.0</p><p>http://creativecommons.org/licenses/by-sa/3.0/us/deed.ru</p><p> LATEX </p><p>P</p><p>a</p><p>peeriapapeeria.com</p><p>http://creativecommons.org/licenses/by-sa/3.0/us/deed.ruhttp://papeeria.com</p></li><li><p> SQL</p><p>3/25</p></li><li><p> - </p><p>4/25</p></li><li><p> :plaintext/json/XML/CSV , , </p><p> , : /</p><p> : , - </p><p> : , </p><p> 5/25</p></li><li><p> , </p><p>6/25</p></li><li><p> : ( ) </p><p> , </p><p>7/25</p></li><li><p> , </p><p>8/25</p></li><li><p>9/25</p></li><li><p> - </p><p>10/25</p></li><li><p> : MySQL, PostgreSQL, SQLite : Oracle, IBM DB2, Microsoft SQLServer</p><p> PostgreSQL</p><p>https://en.wikipedia.org/wiki/Comparison_of_relational_database_management_systems</p><p>11/25</p><p>https://en.wikipedia.org/wiki/Comparison_of_relational_database_management_systemshttps://en.wikipedia.org/wiki/Comparison_of_relational_database_management_systems</p></li><li><p> sudo apt-get install postgresql Windows :https://hub.docker.com/_/postgres/</p><p>12/25</p><p>https://hub.docker.com/_/postgres/</p></li><li><p> PostgreSQL</p><p>13/25</p></li><li><p> SQL</p><p>14/25</p></li><li><p> , (SQL-2011 ) </p><p> SQL , - . , boolean</p><p>15/25</p></li><li><p> SQL</p><p>16/25</p></li><li><p> : INTEGER, BIGINT, SMALLINT :NUMERIC, DECIMAL</p><p> : FLOAT,REAL, DOUBLE PRECISION</p><p> : CHARACTER, CHARACTER VARYING,CLOB</p><p> : DATE, TIME, TIMESTAMP : BOOLEAN</p><p>17/25</p></li><li><p> . </p><p>CREATE TABLE table_name ();</p><p>column_list := [, ...]</p><p>column_def :=column_name []</p><p>data_type := INTEGER | BIGINT | FLOAT | ...</p><p>DROP TABLE table_name;</p><p>https://www.postgresql.org/docs/current/static/sql-createtable.html 18/25</p><p>https://www.postgresql.org/docs/current/static/sql-createtable.htmlhttps://www.postgresql.org/docs/current/static/sql-createtable.html</p></li><li><p>1 CREATE TABLE Foo();2 CREATE TABLE FooBar(INTEGER);3 CREATE TABLE Baz(id INTEGER, value FLOAT,);</p><p>19/25</p></li><li><p>20/25</p></li><li><p>1 INSERT INTO Foo(id, value) VALUES (1, 100);2 INSERT INTO Foo(value, id) VALUES (200, 2), (300, 3);</p><p>21/25</p></li><li><p> SQL-:SELECT-FROM-WHERE</p><p>1 SELECT * FROM Foo WHERE id=1;2 SELECT id FROM Foo WHERE value</p></li><li><p>, - </p><p>1 CREATE TABLE Student(id INT, name TEXT, age INT);2 INSERT INTO Student(id, name, age)3 VALUES (1, Bob, 21), (2, Alice, NULL);4 SELECT * FROM Student WHERE age21;5</p><p>23/25</p></li><li><p>1 SELECT NULL=1;2 SELECT NULL!=1;3 SELECT NULL=NULL;4 SELECT NULL != NULL;</p><p>24/25</p></li><li><p>1 SELECT NULL IS NULL;</p><p>25/25</p><p> SQL </p></li></ul>

Recommended

View more >