I had learned how to create a table for a new database using tools like Excel, Matlab, My sql and table plus.
Now, with SQLite
I can create the databases in a very practical way, it is similar to Mysql
, so today I a practical example, comparing Mysql
with SQLite
,
- We must be in the folder where we will create the database:
To SQLite
in the case of Mysql
, you must find the location of the program to be able to execute it
brew search mysql
//or
./mysql -u root -p
- Open the tool, giving name to database:
To SQLite
~ sqlite3 mydatabase
in the case of Mysql
~ create database mydatabase
- Create new table, taking into account the type of the column:
SQLite
and Mysql
are the same
~ use mydatabase
~ create table dataUsers(
Id integer primary key,
Name text,
Last_name text,
age integer,
Cell integer
)
- insert the data:
SQLite
andMysql
are the same
insert into dataUsers(0001,'Ema','Garces', 21, 0573033333055 );
//or
insert into dataUsers( Name text,Last_name text, age real, Cell integer ) VALUES (0001,'Ema','Garces', 21, 0573033333055);
- Show table:
To SQLite
~ .mode {mode of choice}
~ select * from dataUsers;
there are several view modes to display the table:
ascii, box, csv, column, html, insert, line, list, tabs, tcl, etc.
in the case of Mysql
~ show tables;
~ describe dataUsers;
~ select * from dataUsers;
- Bonus: Connect to database with table plus
6.1 open table plus:
6.2 create new connection:
6.3 name the connection and find the location of the database:
Top comments (0)