Basic understanding of database

DB: Database (database): "warehouse" to store data. It holds a series of organized data.
DBMS: DBMS (Database Management System). DBMS database is through the creation and operation of the vessel.
SQL: Structured Query Language (Structure Query Language): language designed to communicate with the database.
SQL advantage: Almost all DBMS support SQL.
Features of the database:
1. data into a table, place the table in the library
2. A database can have multiple tables, each table has a name, used to represent himself. Show unique.
3. The table has a number of characteristics that define how the data is stored in a table, similar to the java "class" design.
4. The columns of the table, we also called fields. All tables are one or more columns, and each column similar java "Properties."
Table 5. Data is stored in rows, each row in the java like "objects."

DBMS divided into two categories:
- Based on a shared file system DBMS (Access)
- based DBSMS client --- server (Mysql, the Oracle, SQL Server)
---------------- -------------------------------------------------- -
starting and stopping mysql service
NET sTOP mysql1112
NET start mysql1112

Cmd into the mysql command from the
mysql -h localhost -u root -p 3306 -P
mysql [-h hostname] -P port number -u user name -p password
Exit
Exit Ctrl + c
--------- -----------------------------------------------
enter a library ;
use + library name;
view other libraries all tables
show tables from + library name;
see yourself in what is now the library
select database ();
construction of the table:
the Create the table table name (
specified in the type column
the above mentioned id int,
name VARCHAR (20 ));
Display:
Show tables;
Display structure:
desc + name;
see what data:
SELECT * from + name;
insert a data
insert into table (id, name) values (1 , 'join') ;
modify data
update table name set name = 'lilei'where id = 1 ;
delete data
delete from table where id = 1;
how to view the current number, according to the repository 7
One is the mysql "select version ();
the other is C: Windows \ System64" --version MySQL
MySQL -V
---------------------- -------------------------------
Mysql syntax specification
1. not case-sensitive, but there is a standardized keywords capitalized, table name, specify lowercase
2. each command is preferably terminated by a semicolon
3 each command as required, may be indented or line
4. Note
-line comment: # comment text
-line comment: - comment text
multi-line comments : / * comment text * /
------------------------------------------- -------------
aliases:
SELECT 100 AS 98% results;

Deduplication
SELECT DISTINCT
MySQL in the + operator only represents
concat () function, a plurality of splice
IFNULL () function, it is determined whether the air
conditional expression query
--------------- ------------------------------------------

Fuzzy query:
like
a _ represents one character
\ _ escape
escape 'transfer symbol can easily define'
the BETWEEN and
the SELECT * from the Employees the WHERE employss_id the BETWEEN
100 and 200;
contain zero boundary values
in a keyword
where job_id in (value, value, value )
in the list of value types must be consistent or compatible
is null () to determine whether the null
safety and <=> is true there is no null
-------------------- -------------------------------------
the Order dy sort query
group by group representatives
desc descending
asc childhood to large
length () to be byte-length
---------------------------------------- -----------------
common function
upper () uppercase
lower () lowercase
mysql index starting from 1
substr () taken character;
InStr () returns the start index
trim ( ' characters' from 'character') before and after removal character
LPAD () implemented left filled with the specified character
RPAD () Usage opposite
replace () Replace
round () rounding
ceil () rounded up "the smallest integer greater than or equal"
Floor () rounded down
truncate () truncates
MOD () modulo
now () Returns the current date + time
CURDATE () returns the current date time does not include the system
curtime () returns the current system time no date
str_to_date character conversion into the format specified by the date
DATE_FORMAT () is converted into character date
DATEDIFF () differ
IF (,,)
---- -------------------------------------------------- ---
the following function ignores null value
sum () sum
AVG () average
maximum value max ()
min () minimum
count () calculates the number of
counting line numbers may
count (*) count (1)
can be distinct and with
------------------------------------------------- --------

 

Guess you like

Origin www.cnblogs.com/jiazilongBlog/p/11570531.html