in this article I describe about making new database and tables in MySQL database.
- To make a new database on MySQL workbench press database icon in top navbar.It’s like:
writing CREATE SCHEMA nameOf_db;
command on mysql command line - Then insert your new database name and press apply button:
- Now in sidebar find name of your database and right click on it to see create tables option, then click on it:
- in opened window write table name and name of fields in that table and type of data for each field: Before continue it's useful to know about data type in sql:
- CHARACTER [(length)] or CHAR [(length)] ---> strings, including Unicode
- VARCHAR (length) ---> string
- NVARCHAR (lenght) ---> string with other language string
- BOOLEAN ---> TRUE or FALSE
- SMALLINT ---> integer value between the range 2^ -15 and 2^15 -1
- INTEGER or INT ---> integer value between the range 2^ -31 and 2^31 -1
- DECIMAL ---> Precision defaults to 38, Scale defaults to 0
- DECIMAL(p) ---> Scale defaults to 0
- DECIMAL(p, s) ---> Precision and Scale are defined by the user
- NUMERIC [(p[,s])] ---> same way as the DECIMAL data type
- REAL ---> approximate numeric values, up to a precision of 64
- FLOAT(p) ---> approximate numeric values
- DOUBLE PRECISION ---> approximate numeric values
- DATE ---> date values YYYY-MM-DD
- TIME ---> time values HH:MM:SS
- TIMESTAMP ---> timestamp values YYYY-MM-DD HH:MM:SS
- CLOB [(length)] or CHARACTER LARGE OBJECT [(length)] or CHAR LARGE OBJECT [(length)] ---> character strings longer than those that are allowed in the CHARACTER [(length)] or VARCHAR (length) data types
- BLOB [(length)] or BINARY LARGE OBJECT [(length)] ---> binary values we can also use MySQL command prompt to add below codes and create this table without workbranch:
Top comments (2)
Nice work.. Thank you.
Thank you so much