Crear Bases de datos
Sentencia | Concepto |
CREATE DATABE DBBiblioteca; | Crea la base de datos DBBiblioteca |
USE DBBiblioteca; | Esta sentencia activa o habilita la base de datos para poder ser manipulada. Sin esta sentencia no será posible manipular sus datos. |
Create tables
Sentencia | Concepto |
CREATE TABLE tbl_Name ();
e.g => create table tblTipo_Usuario | It allows me to create tables, these ones are going to fill the DB with the information. |
id
id INT(xx) NOT NULL auto_incremental, | The id is a unique number, it will help you to distinguish one register from another.
It must be a NOT NULL field and auto-incremental. |
PRIMARY KEY | Must be defined to identify this table from another, must be always de “id” or the unique code |
NOTE: for making an auto-increment to the primary key you should use: SLQ Server - Identity(1,1) => incrementa la variable asociada en 1 por cada registro. MySQL - auto_increment => increase the associated data-variable in one. If you don’t use a method for auto-increasing you will have an error in your script.
FIELD | Depending on the need you want to solve using the database management tools, you will create different kind of fields, these fields are the variables that compose your table and give it an orden and sense |

ID_USUARIO => It is the primary key
USUARIO, NOMBRE, TELÉFONO => Those are fields that fills up our table
NOTE: you must specify the type of the variable that every field has, it is a good practice also to define how long the field would be, it means, how many characters will have.
Insert data at tables
If you are creating a table and you’re gonna fill in the fields, you should use the method INSERT to do it.
Cautions:
You must make sure that the PRIMARY KEY value is auto-incremental or you’re gonna receive an error.
You must insert as many fields you had created, otherwise you will receive an error message

Other functions
Name | Concept |
GETDATE()
SELECT GET DATE(); => Current date and time | Returns the current database system date and time (YYYY-MM-DD hh:mm:ss) |
Comentarios
Publicar un comentario