You are on page 1of 5

Setting environment for using XAMPP for Windows.

nadia@KHYRA c:\xampp
# mysql -u root
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 8
Server version: 10.4.32-MariaDB mariadb.org binary distribution

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> use 07_practica_nadia;


Database changed
MariaDB [07_practica_nadia]> create table persona4(id int, nombre
varchar(39),apellidos varchar(39),edad int, constraint pk1 primary key(id));
Query OK, 0 rows affected, 1 warning (0.171 sec)

MariaDB [07_practica_nadia]>
MariaDB [07_practica_nadia]> show create table persona;
+---------
+----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
--+
| Table | Create Table |
+---------
+----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
--+
| persona | CREATE TABLE `persona` (
`idp` int(11) DEFAULT NULL,
`app` varchar(30) DEFAULT NULL,
`amp` varchar(30) DEFAULT NULL,
`edadp` int(11) DEFAULT NULL,
UNIQUE KEY `idp` (`idp`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci |
+---------
+----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
--+
1 row in set (0.090 sec)

MariaDB [07_practica_nadia]> show create table persona4;


+----------
+----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
+
| Table | Create Table

|
+----------
+----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
+
| persona4 | CREATE TABLE `persona4` (
`id` int(11) NOT NULL,
`nombre` varchar(39) DEFAULT NULL,
`apellidos` varchar(39) DEFAULT NULL,
`edad` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci |
+----------
+----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
+
1 row in set (0.005 sec)

MariaDB [07_practica_nadia]> alter table drop persona4 primary key;


ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MariaDB server version for the right syntax to use near 'drop
persona4 primary key' at line 1
MariaDB [07_practica_nadia]>
MariaDB [07_practica_nadia]> alter table persona4 primary key;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MariaDB server version for the right syntax to use near
'primary key' at line 1
MariaDB [07_practica_nadia]> alter table drop persona4 primary key;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MariaDB server version for the right syntax to use near 'drop
persona4 primary key' at line 1
MariaDB [07_practica_nadia]> alter table persona4 drop primary key;
Query OK, 0 rows affected (0.836 sec)
Records: 0 Duplicates: 0 Warnings: 0

MariaDB [07_practica_nadia]> alter table persona4 add constraint pkn primary


key(id);
Query OK, 0 rows affected, 1 warning (0.822 sec)
Records: 0 Duplicates: 0 Warnings: 1

MariaDB [07_practica_nadia]> describe persona4;


+-----------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------+-------------+------+-----+---------+-------+
| id | int(11) | NO | PRI | NULL | |
| nombre | varchar(39) | YES | | NULL | |
| apellidos | varchar(39) | YES | | NULL | |
| edad | int(11) | YES | | NULL | |
+-----------+-------------+------+-----+---------+-------+
4 rows in set (0.044 sec)

MariaDB [07_practica_nadia]> create table orden(id int, num_orden int, id_persona


int, constraint pks primary key(id), constraint fk1 foreign key (id_persona)
references persona4(id));
Query OK, 0 rows affected, 1 warning (0.283 sec)

MariaDB [07_practica_nadia]> create table orden(id int, num_orden int, id_persona


int, constraint pks primary
key(id), constraint fk1 foreign key (id_persona) references persona4(id));
ERROR 1050 (42S01): Table 'orden' already exists
MariaDB [07_practica_nadia]> show table orden;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MariaDB server version for the right syntax to use near 'orden'
at line 1
MariaDB [07_practica_nadia]> describe orden;
+------------+---------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------+---------+------+-----+---------+-------+
| id | int(11) | NO | PRI | NULL | |
| num_orden | int(11) | YES | | NULL | |
| id_persona | int(11) | YES | MUL | NULL | |
+------------+---------+------+-----+---------+-------+
3 rows in set (0.050 sec)

MariaDB [07_practica_nadia]> alter table orden drop foreign key fk1;


Query OK, 0 rows affected (0.441 sec)
Records: 0 Duplicates: 0 Warnings: 0

MariaDB [07_practica_nadia]> alter table orden add constraint fk1 foreign key
(id_persona) references persona4(id);
Query OK, 0 rows affected (1.046 sec)
Records: 0 Duplicates: 0 Warnings: 0

MariaDB [07_practica_nadia]> describe tables;


ERROR 1146 (42S02): Table '07_practica_nadia.tables' doesn't exist
MariaDB [07_practica_nadia]> describe table;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MariaDB server version for the right syntax to use near 'table'
at line 1
MariaDB [07_practica_nadia]> show table;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MariaDB server version for the right syntax to use near '' at
line 1
MariaDB [07_practica_nadia]> show 07_practica_nadia;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MariaDB server version for the right syntax to use near
'07_practica_nadia' at line 1
MariaDB [07_practica_nadia]> show tables;
+-----------------------------+
| Tables_in_07_practica_nadia |
+-----------------------------+
| categoria |
| categoria2 |
| orden |
| persona |
| persona1 |
| persona2 |
| persona4 |
| usuario |
+-----------------------------+
8 rows in set (0.003 sec)

MariaDB [07_practica_nadia]> describe persona4;


+-----------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------+-------------+------+-----+---------+-------+
| id | int(11) | NO | PRI | NULL | |
| nombre | varchar(39) | YES | | NULL | |
| apellidos | varchar(39) | YES | | NULL | |
| edad | int(11) | YES | | NULL | |
+-----------+-------------+------+-----+---------+-------+
4 rows in set (0.061 sec)
MariaDB [07_practica_nadia]> describe orden;
+------------+---------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------+---------+------+-----+---------+-------+
| id | int(11) | NO | PRI | NULL | |
| num_orden | int(11) | YES | | NULL | |
| id_persona | int(11) | YES | MUL | NULL | |
+------------+---------+------+-----+---------+-------+
3 rows in set (0.035 sec)

MariaDB [07_practica_nadia]> show create table persona4;


+----------
+----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
+
| Table | Create Table

|
+----------
+----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
+
| persona4 | CREATE TABLE `persona4` (
`id` int(11) NOT NULL,
`nombre` varchar(39) DEFAULT NULL,
`apellidos` varchar(39) DEFAULT NULL,
`edad` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci |
+----------
+----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
+
1 row in set (0.001 sec)

MariaDB [07_practica_nadia]> show create table orden;


+-------
+----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
------------------------------------------------------------------+
| Table | Create Table

|
+-------
+----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
------------------------------------------------------------------+
| orden | CREATE TABLE `orden` (
`id` int(11) NOT NULL,
`num_orden` int(11) DEFAULT NULL,
`id_persona` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `fk1` (`id_persona`),
CONSTRAINT `fk1` FOREIGN KEY (`id_persona`) REFERENCES `persona4` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci |
+-------
+----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
------------------------------------------------------------------+
1 row in set (0.001 sec)

MariaDB [07_practica_nadia]>

You might also like