Create database in mysql linux




Reminder. Riding a database with two tables of shopping and other products. A reference set of one another and some form of semantic principle. How do you get to meet CIA?


create database actividad1 character set latin1 collate latin1_spanish_ci ;


use actividad1;

/**create tables**/

mysql> create table compra(Idcompra varchar(20) primary key default 'SINid',Nomcompra varchar (30),idpro varchar(20) );
Query OK, 0 rows affected (0.09 sec)

mysql> create table producte (idpro varchar(20) primary key default 'SinID',Nompro varchar(30),idcompra varchar(20),foreign key (idcompra) REFERENCES compra (idcompra) on delete no action on update cascade);
Query OK, 0 rows affected (0.11 sec)


/** insert values **/

mysql> insert into compra values (54,'hhh');
Query OK, 1 row affected (0.04 sec)

mysql> insert into compra values (50,'ddd');
Query OK, 1 row affected (0.04 sec)

mysql> insert into producte values(50,'aaa',50);
Query OK, 1 row affected (0.05 sec)

mysql> insert into producte values(4,'aaa',54);
Query OK, 1 row affected (0.04 sec)




Comments

Popular posts from this blog

How to install coWPAtty 4.6 on Ubuntu?

how to install dhcp on debian VirtualBox

How to install vsftpd on linux ?