Answers for "create database and table in mysql"

SQL
13

create database mysql

CREATE DATABASE `mydb`;

CREATE TABLE `my_table`
(
	my_table_id INT AUTO_INCREMENT,
    my_table_name VARCHAR(30) NOT NULL,
    my_foreign_key INT NOT NULL,
    my_tb_created TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  	my_tb_updated TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, ,
    # Any other properties here
    PRIMARY KEY(my_table_id),
    CONSTRAINT fk_name_of_parent_table
    FOREIGN KEY(my_foreign_key) REFERENCES parent_table(parent_table_column)
);

SHOW DATABASES;
Posted by: Guest on February-08-2020
0

create mysql database

mysql -u username -p
CREATE DATABASE dbname;
Posted by: Guest on August-08-2021
2

MySQL CREATE DATABASE

MySQL implements a database as a directory that contains all files which correspond to tables in the database.

To create a new database in MySQL, you use the CREATE DATABASE statement with the following syntax:

CREATE DATABASE [IF NOT EXISTS] database_name
[CHARACTER SET charset_name]
[COLLATE collation_name]
Posted by: Guest on October-19-2020
-1

mysql create the database and table

<?php
CREATE TABLE IF NOT EXISTS `my_contacts` (

  `id` int(11) NOT NULL AUTO_INCREMENT,

  `full_names` varchar(255) NOT NULL,

  `gender` varchar(6) NOT NULL,

  `contact_no` varchar(75) NOT NULL,

  `email` varchar(255) NOT NULL,

  `city` varchar(255) NOT NULL,

  `country` varchar(255) NOT NULL,

  PRIMARY KEY (`id`)

) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;

INSERT INTO `my_contacts` (`id`, `full_names`, `gender`, `contact_no`, `email`, `city`, `country`) VALUES

(1, 'Zeus', 'Male', '111', 'zeus @ olympus . mt . co', 'Agos', 'Greece'),

(2, 'Anthena', 'Female', '123', 'anthena @ olympus . mt . co', 'Athens', 'Greece'),

(3, 'Jupiter', 'Male', '783', 'jupiter @ planet . pt . co', 'Rome', 'Italy'),

(4, 'Venus', 'Female', '987', 'venus @ planet . pt . co', 'Mars', 'Italy');
?>
Posted by: Guest on June-17-2021

Code answers related to "create database and table in mysql"

Code answers related to "SQL"

Browse Popular Code Answers by Language