Linux na web /Como armazenar informação?/SQL/
- Conexão
$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2 to server version: 3.22.32
Type 'help' for help.
mysql> use mono;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql>
- Criação de uma tabela:
mysql> create table bidic (p2 char(20), p1 char(20), p0 char(20) );
- Inserção de dados na tabela:
mysql> insert into bidic values ("a","palestra","estah");
Query OK, 1 row affected (0.05 sec)
- Consulta a dados:
mysql> select * from bidic limit 10;
+-------+-------+----------+
| p2 | p1 | p0 |
+-------+-------+----------+
| | | vamos |
| | vamos | ver |
| vamos | ver | como |
| ver | como | isso |
| como | isso | se |
| isso | se | comporta |
| | | vamos |
| | vamos | ver |
| vamos | ver | como |
| ver | como | isso |
+-------+-------+----------+
- Consulta a dados de acordo com um condição
mysql> select * from bidic where (p0 = "estah") limit 10;
+------+----------+-------+
| p2 | p1 | p0 |
+------+----------+-------+
| a | palestra | estah |
+------+----------+-------+
1 row in set (0.00 sec)
- Removendo um item da tabela
mysql> delete from bidic where (p0 = "estah");
Query OK, 1 row affected (0.00 sec)
CGI-script com SQL
autor: Jorge Kinoshita