mysql commands - statements

database tables

a database most often contains one or more tables.each table is identified by a name(e.g 'show','1212').tables contain records with data.

look below is a 'customers' table

idcustomernamecitypostalcodecountry
1sandeeplaxmangarh332311india
2vinodjaipur654011india
3mysqlcommand332110usa
4krishnawashington222222usa

the table above contains four records and five columns(id ,coustomername, city,postalcode,
country
).


mysql statements

some important points about the MySQL

MySQl is not case sensitive: create is the same as create.

semicolon is the standard way to separate each mysql statement in database systems.

mysql doesn't permit two databases of the same name.

names for database, tables, columns, and indexes can be up to 64 characters long.

every mysql statement ends in a semicolon, and white space, tabs, and carriage return are ignored by the mysql processor.

most of the actions you need to perform on a database are done with mysql statements.

syntax

            create table  sandeep (
            
                         id        int(10)     not null,
                         
                         name   varchar(255)     not null,
                         
                         primary key  (id)
                        
                         );

mysql statements can be divided into three broad categories.

statement used to define the structure of a datebase :

these statements define the relationship among different pieces of data, definition for database,table and column types, and database indices.(data definition language)ddl

statements used to manipulate data

these statement control adding and removing records, querying and joining tables.(data manipulation language)dml.

statements used to control the permission and access level to different pieces of data :

statements define the access levels and security privilegs for database, tables and fields, which may be specified on a per-user and per-host basis.(data control language)dcl.


some of the most important mysql commands

  • create table - creates a new table
  • create database - creates a new database
  • create index - creates an index(search key)
  • drop table - deletes a table
  • drop index - deletes an index
  • alter database - modifies a database
  • alter table - modifies a table
  • select - extracts data from a database
  • update - updates data in a database
  • delete - deletes data from a database