---
title: "FAQ: Bases de Datos y modelos"
version: 1.9
locale: es
source: https://docs.djangoproject.com/es/1.9/faq/models/
canonical: https://djangodocs.dev/es/1.9/faq/models/
---
# FAQ: Bases de Datos y modelos

## ¿Cómo puedo ver las consultas SQL plano que Django está ejecutando?

Make sure your Django [`DEBUG`](/es/1.9/ref/settings/#std-setting-DEBUG) setting is set to `True`.
Then, just do this:

```
>>> from django.db import connection
>>> connection.queries
[{'sql': 'SELECT polls_polls.id, polls_polls.question, polls_polls.pub_date FROM polls_polls',
'time': '0.002'}]
```

`connection.queries` is only available if [`DEBUG`](/es/1.9/ref/settings/#std-setting-DEBUG) is `True`.
It’s a list of dictionaries in order of query execution. Each dictionary has
the following:

```
``sql`` -- The raw SQL statement
``time`` -- How long the statement took to execute, in seconds.
```

`connection.queries` includes all SQL statements – INSERTs, UPDATES,
SELECTs, etc. Each time your app hits the database, the query will be recorded.

If you are using [multiple databases](/es/1.9/topics/db/multi-db/), you can use the
same interface on each member of the `connections` dictionary:

```
>>> from django.db import connections
>>> connections['my_db_alias'].queries
```

If you need to clear the query list manually at any point in your functions,
just call `reset_queries()`, like this:

```
from django.db import reset_queries
reset_queries()
```

## ¿Puedo usar Django con una base de datos ya existente?

Yes. See [Integrating with a legacy database](/es/1.9/howto/legacy-databases/).

## Si hago cambios en un modelo, ¿cómo actualizo la base de datos?

Take a look at Django’s support for [`schema migrations`](/es/1.9/topics/migrations/#module-django.db.migrations).

If you don’t mind clearing data, your project’s `manage.py` utility has a
[`flush`](/es/1.9/ref/django-admin/#django-admin-flush) option to reset the database to the state it was in
immediately after [`migrate`](/es/1.9/ref/django-admin/#django-admin-migrate) was executed.

## ¿Django soporta modelos de múltiples columnas en llaves primarias?

No. Sólo son soportadas llaves primarias de columna única.

But this isn’t an issue in practice, because there’s nothing stopping you from
adding other constraints (using the `unique_together` model option or
creating the constraint directly in your database), and enforcing the
uniqueness at that level. Single-column primary keys are needed for things such
as the admin interface to work; e.g., you need a simple way of being able to
specify an object to edit or delete.

## ¿Soporta Django bases de datos NoSQL?

NoSQL databases are not officially supported by Django itself. There are,
however, a number of side project and forks which allow NoSQL functionality in
Django, like [Django non-rel](http://django-nonrel.org/).

También puedes echar un vistazo en la “página Wiki’\_ que discute algunas alternativas.

## How do I add database-specific options to my CREATE TABLE statements, such as specifying MyISAM as the table type?

We try to avoid adding special cases in the Django code to accommodate all the
database-specific options such as table type, etc. If you’d like to use any of
these options, create a migration with a
[`RunSQL`](/es/1.9/ref/migration-operations/#django.db.migrations.operations.RunSQL) operation that contains
`ALTER TABLE` statements that do what you want to do.

Por ejemplo, si está usando MySQL y quiere que sus tablas usen el tipo de tabla MyISAM, use la siguiente sentencia SQL:

```
ALTER TABLE myapp_mytable ENGINE=MyISAM;
```
