Summary of what you should know after this session Then you’re back to seeing the results of commands in the interactive shell again! In this case, only the first following command will be redirected to the file, in other words, only the. It will redirect the output once, to the specified file. Hint: If you are unfamiliar with redirecting streams in bash, you can read about it in the Bash redirection chapter of our introduction to bash book.Įxit the database again and in the shell, open your favorite text editor, and create a file called my_books.sql in the current directory, and let the text content be exactly this before you save the file: If you want to see how you can investigate tables etc in MariaDB, please see This page Task 7 - Create an SQL text file with books The syntax in this question works for SQLite3. The syntax in this question differs a lot from the syntax used in MariaDB. Remember, commands inside the SQLite3 interactive shell, which start with a dot are SQLite3-specific commands and not part of the SQL language. This command will echo back the create table statement, revealing how the books table was created (what the names and types are for the columns in the table). Task 2 -Create a database called my_books If you see Command not found, you either didn't succeed to install it or it is not in your PATH. If you have problems finding the database category, make sure the installer isn't showing only "Pending" packages. Restart your Cygwin terminal and you should be set. You can also search for sqlite in the search box of the installer. You'll find the package "sqlite" listed in the "All" category. Then, run setup and answer all of the questions. To install the SQLite package, click on the "Install Cygwin now" link on the web page or run your installer again if you already installed Cygwin (the file is usually called setup(X86).exe or something similar). Read this first install additional software in cygwin. If that doesn't work, ask a class mate or colleague or the teachers. If you can't install it following the instructions above, use a search engine to find out how to install sqlite3 on Mac OS and follow the instructions you find. You need to install it as root (using sudo). Mac App Store: Install sqlite on Mac OSX or.If you are running Mac OS, please refer to the instructions here: If you are running Ubuntu this is as simple as issuing the following command: $ sqlite3 books (when the database file is actually stored in books.db, then sqlite3 won't warn you, but instead create an empty database and use that.Įxercise for the Getting started with SQLite chapter Notes on typographyĬommands are written in a fixed width font and commands issued in a terminal in your computer shell are prefixed with a $.Ĭommands issued inside the SQLite3 interactive shell are prefixed with sqlite>Įxample: List the files in the current directory using the command ls: You may choose any name for your database files, but be consistent!.books.db - contains the database in a format that only sqlite can understand (not readable for humans).books.sql - contains ASCII text with SQL statements for books, tables etc.It is especially useful to use file-endings if you have two files relating to the same data.Some of the exercises use such names, other use names with no file-ending at all, e.g.It might be wise to name the database files with a file-ending of.This file can be named anything - the name doesn't change the contents of the file.The database is stored in a binary (non-text) file.2.12 Summary of what you should know after this session.2.11 Task 10 - Create a backup SQL text file using.2.10 Task 9 - Feel free to examine various commands.2.9 Task 8 - Look at the books table contents.2.8 Task 7 - Create an SQL text file with books.2.7 Task 6 - Investigate the my_books database.2.6 Task 5 - Enter your database in various ways.2.5 Task 4 - Log out from the database and examine stuff.2.4 Task 3 - Create a table in your newly created database.2.3 Task 2 -Create a database called my_books. 2 Exercise for the Getting started with SQLite chapter.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |