These are all analogous to data types which you have learned about in javascript.įor "paid" which is either yes ( 1) or no ( 0) - we have a default of no ( 0)- it's saying that if you insert data and don't specify 'paid' as a column when you INSERT data, it will assume you meant 'no'.įor 'invoice_date_time' you must store the data in the form of a combination of date and time. Paid boolean default 0 ) insert into invoices (id, total, invoice_date_time, paid ) values ( 123, 3444.50, '', 1 ) insert into invoices (id, total, invoice_date_time ) values ( 124, 3445.50, '' ) Īnd in the command box: select * from invoices Īn 'integer', a 'number', a 'datetime' and a 'boolean'. My email address is 1D: Data types and directives create table invoices ( Add teacher - "Colm OConner" - as your third customer. Select everythin agian, and ensure you are both guests.Ĭhange hotel.sql again. Run select * from customers and ensure that you see yourself both as guests.Ĭhange hotel.sql again to store email addresses from yourself and Donald and have them displayed on screen. EXERCISE 1C: Create tables and insert dataĪmend hotel.sql create the database again and add yourselves as second customer using INSERT - so you're now staying in a hotel with Donald Trump. This means that for each exercise we will be adding sql statements to our hotel.sql and then read this file into sqlite3 to create our database, because everytime we close sqlite3 the database will be deleted and the data will be lost. This should display: sqlite> select * from customers Out again like this: select * from customers Now that the file has been loaded with one table containing one row of data, you can read it back Now, in the command prompt run the following: $ sqlite3 -init hotel.sql This is pretty much the same thing as a string in javascript.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |