How to Create Databases, Tables, and Data Types in MySQL

MySQL Database Management Manual.

Have you ever been obsessed with… How do you create databases? In this tutorial we will show you how to perform some of the most common MySQL database management tasks from the command line using the MySQL command line tool.

PLEASE NOTE: This article does not cover MySQL management tools included in the cPanel standard installation. If you have any questions or technical requests, please do not hesitate to contact our support team via the ticket system or live chat.

MySQL – Overview

MySQL is the world’s most popular relational database management system. It is free and open source software compatible with most modern operating systems. MySQL works by connecting to databases and manipulating them easily and clearly using SQL commands.

PHP and MySQL are the basis of the LAMP stack (Linux, Apache, MySQL and PHP), the software configuration used to host most websites currently available on the Internet. Using the SQL language, MySQL stores data in tables that are related datasets consisting of columns and rows.

MySQLProperties

client/server architecture : MySQL runs on a client/server system. This means that a main database server is running under MySQL, with a large number of clients (applications) that are in contact with the main server. These connections will consist of data retrieval, recording changes to databases, etc. The customers work either on the same computer as the server, or on a separate computer connected to the Internet or a local network.

SQL compatibility : MySQL supports SQL (Structured Query Language) as the database language. SQL is a widely accepted standard language used for both database updates and data queries.

cash: Views are SQL queries that are treated as separate database objects, available in MySQL version 5.0 and later.

Trigger: Triggers are SQL commands that are executed automatically when a specific database operation triggers the command.

Repeat: In replication, the content of the database is copied or replicated to multiple computers.

Operations : A transaction occurs when multiple database transactions are executed in one block, with the database system ensuring that all or none of the transactions are executed.

Platform independence : MySQL can run on a wide range of operating systems, including Mac OS X, Windows, Linux and many others.

Restrictions for the external key : These are rules to ensure that no cross-references in the linked tables lead nowhere.

ODBC : ODBC interfaces give you access to MySQL in all languages running on Microsoft Windows.

MySQL Datatypes

MySQL has different types of data, so we will classify them as such:

  • Types of digital data
  • Date and time
  • Types of lines
  • Types of digital data

MySQL uses the following common numeric data types:

INT : A normal integer that may or may not be signed. If the sign is signed, the permitted range is -2147483648 to 2147483647. If not signed, the acceptable range is 0 to 4294967295.

TINYINT: A very small integer that may or may not be signed. When signed, the permitted range is -128 to 127. If it is not signed, the acceptable range is 0 to 255. You can specify a width of up to 4 digits.

SALLINT: A small integer that may or may not be signed. If signed, the permitted range is -32768 to 32767. If not signed, the acceptable range is 0 to 65535. You can specify a width of up to 5 digits.

MEDIUMINT: The average integer that may or may not be signed. If signed, the acceptable range is -8388608 to 8388607. If not signed, the acceptable range is 0 to 16777215. You can specify a width of up to 9 digits.

WARREN: WARREN: WARREN: WARREN: WARREN: WARREN: A large integer that may or may not be signed. If signed, the acceptable range is between -9223372036854775808 and 9223372036854775807 If unsigned, the acceptable range is between 0 and 18446744073709551615 You can specify a width of up to 20 characters.

PLOAT [M,D]: A floating point number that must be signed and cannot be unsigned. You determine the display time (M) and the number of decimals (D).

DUBEL [M,D]: A double precision floating point number, which must be signed and not unsigned. You determine the display time (M) and the number of decimals (D).

DECISION (M, D) : Unpackaged floating point number that must be signed and cannot be unsigned. You determine the display time (M) and the number of decimals (D).

Type of date and time

MySQL uses the following data types: date and time :

DATA: Date in standard format YYYYY-MM-DD.

DATA: Combination of date and time in standard format YYYYY-MM-DD HH:MM:SS

IT IS TIME: Time stamp in standard DATETIME format, but without dashes between the digits.

IT IS TIME: Time in standard format HH:MM:SS.

THE YEAR OF NAME: year in 2 or 4 bit format.

Line types

MySQL uses the following string data types :

CHAR: A character string of fixed length from 1 to 255 characters, completed with spaces.

VARCHAR: Chain of variable length between 1 and 255, of a given length

BLOB/TEXT : BLOB or TEXT column with a maximum number of 65535 characters

PINKY/TINITEX: BLOB or TEXT column of up to 255 characters.

MEDIUM DROPLET/MEDIUM TEXT : BLOB or TEXT column with a maximum length of 16777215 characters.

MEDIUM DROPLET/MEDIUM TEXT : BLOB or TEXT column with a maximum number of characters 4294967295.

ENUM: List or list of elements from which the value is to be selected

Creation and selection of the database

In this section you will learn how to create and select a MySQL database.

First log in to MySQL as root user of the :

mysql -u Carrot -p

Enter the MySQL root password and press Enter to log in.

To create a database, type the following command, replacing dbname with the name of the database you want to create:

CREATE A dbname DATABASE ;

To select a database, simply use the following command, replacing the dbname with the name of the database

Use of Dbname

Adding users to MySQL

In this section you will learn how to add a user to your MySQL database.

First use the following command to add a new user to the server by replacing the username and password with a password :

USER CREATION newuser@localhost IDENTIFIED with a password ;

We must now give permission to the user of the database. So we have to use the following command to assign all rights to the new user:

TO GRANT ALL PRIVILEGES IN… * As a newcomer, as a local champion

Creating a MySQL table

In this section you will learn how to add a table to our MySQL database.

For this we will use the CREATE TABLE statement with the speakers. In this example we use the columns ID, first name, last name and email address:

MyTable Create MyTable (

id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,

Name VARCHAR(30) NOT NULL,

Last name VARCHAR(30) NOT NULL,

VARCHAR(50) e-mail,

)

Inserting data into MySQL tables

This chapter explains how to insert data into our MySQL table.

First we need to use the INSERT INTO operator to enter data into our database table. It is used in combination with the data insertion columns:

IN MY TABLE (ID, first name, last name, e-mail)

It is now necessary to indicate the values to be inserted in these columns:

VALUES (1, Tom, Smith, [email protected]);

Removing data from MySQL tables

This section explains how to remove data from our MySQL table.

To do this, you must use the DELETE FROM command, followed by the name of the database table and what you need to delete. This example deletes the entry from the MyTable database table, where the first name is Tom:

REMOVE FROM MY TABLE WHERE NAME=TOM ;

Removing tables and databases in MySQL

This section shows you how to remove tables and databases from our MySQL server.

Deletion of tables

To remove a MySQL table, we need to use the DROP TABLE operation followed by the name of the table. In this example we remove the table called MyTable :

A hidden MayTable badge;

Disposal of databases

To delete a MySQL database, we must use the DROP DATABASE command followed by the name of the database. In this example we remove the database named first_database :

DROP DATABASE first_database ;

In all our plans you will find an unlimited number of databases and many powerful features that we have added especially for you.

Do you need our help? Do you have a question?

If you need our help, don’t hesitate to contact the Super Friend support team, available 24 hours a day on our ticketing platform or directly via our live chat. In addition, you can always consult the frequently asked questions that our support team receives.

Related Tags:

create table in mysql w3schools,create employee table in mysql,how to insert values in table in mysql,how to create a database for a company,steps in creating a database,how to create table in mysql command line,mysql create table primary key,view a table mysql,insert into table mysql,mysql create table foreign key,how to view data in mysql,mysql create table from file,mysql data types cheat sheet,mysql data types w3schools,mysql 5.7 data types,tinyint in mysql example,bigint mysql,difference between int and number in mysql,create table student details in sql,a relational database must have only one,student database tables examples,list ddl and dml commands of database,command to create a table structure in foxpro,why are data types used in dbms and rdbms,phone number data type in mysql,how to insert float value in mysql,mysql password data type,create employee table in mysql example,create employee table in sql,create table in mysql with constraints,sql syntax create table if not exists,create database query,list out different types of tcl commands.,sql float vs decimal,sql data types pdf,decimal(10,2 means in sql server),oracle sql data types,data types in programming,column_name sql,mysql queries examples with answers,mysql commands with examples pdf,mysql query examples,mysql syntax cheat sheet,database tables examples,create table with password field in mysql,how to create table in mysql workbench,mysql data types,how to create a database in mysql,how to select database in mysql,how to create database and table in mysql