MySQL Syntaxes - 241023 - 235003
MySQL Syntaxes - 241023 - 235003
MySQL Syntaxes - 241023 - 235003
[black is for syntaxes, italicised black is for code specific things that will change according to
code (eg: database_name, column_name etc), green is for explanations, red is for code
examples]
2. use database_name;
- sets the created database as the default database being used
- use employee;
4. desc table_name;
- gives details of the table including information on datatypes
- desc employee_data;
7. show databases;
- shows all databases
- show databases;
12. create table table_name (column_name datatype primary key, column_name datatype
default value);
- set a default value to the column (will be ignored if data is given for the column)
- create table students (regno int primary key, class varchar(10), dept varchar(10) default
‘BBA’);
- note that when this is used, the insert into command changes syntax a bit
- insert into students (regno, class) values (2320721, “3BBAG”);
- to override the default just insert data as you would normally
- insert into students values(234287, “3BCOMSF”,”COMM”);
String Operations:
1. select concat(“value”,”value”);
- join two string values (to add space in between do: select concat(“value”,” “,”value”))
- select concat(“hello”,” “,”world);
4. select reverse(“value”);
- returns value reversed (eg: hello as olleh)
- select reverse(“hello”);
5. select upper(“value”);
- returns value in uppercase (hello as HELLO)
- select upper(“hello”);
6. select lower(“value”);
- returns value in uppercase (HELLO as hello)
- select lower(“hello”);