MySQL – functions, administrative commands, datatypes

 0    161 fiszek    sir
ściągnij mp3 drukuj graj sprawdź się
 
Pytanie język polski Odpowiedź język polski
Returns the ASCII value for the specific character
rozpocznij naukę
ASCII(text)
Returns the length of a string (in characters)
rozpocznij naukę
CHARACTER_LENGTH(text)
=CHAR_LENGTH(text)
Concatenates two or more expressions together
rozpocznij naukę
CONCAT(arg1, arg2, ...)
Concatenates two or more expressions together with a separator
rozpocznij naukę
CONCAT_WS(sep, arg1, arg2, ...)
Returns the index position of a value in a list of values
rozpocznij naukę
FIELD(arg1, arg2, ...)
Returns the position of a string within A LIST OF strings
rozpocznij naukę
FIND_IN_SET(searched_string, s1, s2, s3, ...)
Formats a number to a format like "#,###,###.##", rounded to a specified number of decimal places
FORMAT(12678.90, 2)
rozpocznij naukę
FORMAT(number, decimals)
"12,678,90"
Inserts a string within a string at the specified position and for a certain number of characters
rozpocznij naukę
INSERT(text, position, n, s)
n − number of characters to replace
Returns the position of the first occurrence of a string in another string
rozpocznij naukę
INSTR(text, s)
Converts a string to lower-case
rozpocznij naukę
LCASE(text)
=LOWER(text)
Extracts a number of characters from a string (starting from left)
rozpocznij naukę
LEFT(text, n)
Returns the length of a string (in bytes)
rozpocznij naukę
LENGTH(text)
Returns the position of the first occurrence of a substring in a string
rozpocznij naukę
LOCATE(s, text, start)
=POSITION(...)
Left-pads a string with another string, to a certain length
rozpocznij naukę
LPAD(text, width, s)
Corresponds Python 3 rjust()
Removes leading spaces from a string
rozpocznij naukę
LTRIM(text)
Repeats a string as many times as specified
rozpocznij naukę
REPEAT(text, n)
Replaces all occurrences of a substring within a string, with a new substring
rozpocznij naukę
REPLACE(text, s1, s2)
Similar to Python's 3.
Reverses a string and returns the result
rozpocznij naukę
REVERSE(text)
Extracts a number of characters from a string (starting from right)
rozpocznij naukę
RIGHT(text, n)
Right-pads a string with another string, to a certain length
rozpocznij naukę
RPAD(text, width, s)
Removes trailing spaces from a string
rozpocznij naukę
RTRIM(text)
Returns a string of the specified number of spaces.
rozpocznij naukę
SPACE(number)
Compares two strings
rozpocznij naukę
STRCMP(s1, s2)
returns -1 or 0 or 1
Extracts a substring from a string (starting at any position)
rozpocznij naukę
SUBSTRING(text, start, len)
=SUBSTR(...)=MID(...)
Returns a substring of a string before a specified number of DELIMITER occurs
rozpocznij naukę
SUBSTRING_INDEX(text, delimiter, quantity)
Removes leading and trailing spaces from a string
rozpocznij naukę
TRIM(text)
Converts a string to upper-case
rozpocznij naukę
UCASE(text)
=UPPER(text)
Adds a time/date interval to a date and then returns the date
rozpocznij naukę
ADDDATE(date/datetime, interval)
adddate(current_date(), INTERVAL 3 minute)
Adds a time interval to a time/datetime and then returns the time/datetime
rozpocznij naukę
ADDTIME(time/datetime, interval)
Returns the current date
rozpocznij naukę
CURRENT_DATE()
=CURDATE()
Returns the current time
rozpocznij naukę
CURRENT_TIME()
=CURTIME()
Extracts the date part from a datetime expression
rozpocznij naukę
DATE(datetime)
Returns the number of days between two date values
rozpocznij naukę
DATEDIFF(date1, date2)
Adds a time/date interval to a date and then returns the date
rozpocznij naukę
DATE_ADD(date, interval)
Formats a date
rozpocznij naukę
DATE_FORMAT(date, format_specifier)
Subtracts a time/date interval from a date and then returns the date
rozpocznij naukę
DATE_SUB(date, interval)
Returns the day of the month for a given date
rozpocznij naukę
DAY(date[time])
Returns the weekday NAME for a given date
rozpocznij naukę
DAYNAME(date[time])
Returns the day of the month for a given date
rozpocznij naukę
DAYOFMONTH(date[time])
Returns the weekday number for a given date
rozpocznij naukę
DAYOFWEEK(date[time])
Returns the day of the year for a given date
rozpocznij naukę
DAYOFYEAR(date[time])
Extracts a part from a given date
rozpocznij naukę
EXTRACT(time_unit FROM date/time)
Returns a date from a numeric datevalue
rozpocznij naukę
FROM_DAYS(day_quantity)
Returns the hour part for a given date
rozpocznij naukę
HOUR([date]time)
Extracts the last day of the month for a given date
rozpocznij naukę
LAST_DAY([date]time)
Returns the current date and time
rozpocznij naukę
NOW()
LOCALTIMESTAMP(), localtime(), sysdate(), CURRENT_TIMESTAMP()
Creates and returns a date based on a year and a number of days value
rozpocznij naukę
MAKEDATE(year, minute, second)
Creates and returns a time based on an hour, minute, and second value
rozpocznij naukę
MAKETIME(hour, minute, second)
Returns the microsecond part of a time/datetime
rozpocznij naukę
MICROSECOND([date]time)
Returns the minute part of a time/datetime
rozpocznij naukę
MINUTE([date]time)
Returns the month part for a given date
rozpocznij naukę
MONTH(date[time])
Returns the name of the month for a given date
rozpocznij naukę
MONTHNAME(date[time])
Adds a specified number of months to a period
rozpocznij naukę
PERIOD_ADD(period, number)
SELECT PERIOD_ADD(201703, 15);
Returns the difference between two periods
rozpocznij naukę
PERIOD_DIFF(period, number)
SELECT PERIOD_DIFF(1703, 1612);
Returns the quarter of the year for a given date value
rozpocznij naukę
QUARTER([date]time)
Returns the seconds part of a time/datetime
rozpocznij naukę
SECOND([date]time)
Returns a time value based on the specified seconds
rozpocznij naukę
SEC_TO_TIME(seconds)
Returns a date based on a string and a format
rozpocznij naukę
STR_TO_DATE(text, format_specifier)
Subtracts a time/date interval from a date and then returns the date
rozpocznij naukę
SUBDATE(date, interval)
Subtracts a time interval from a datetime and then returns the time/datetime
rozpocznij naukę
SUBTIME(time, interval)
Extracts the time part from a given time/datetime
rozpocznij naukę
TIME(datetime)
Formats a time by a specified format
rozpocznij naukę
TIME_FORMAT(time, format_specifier)
Converts a time value into seconds
rozpocznij naukę
TIME_TO_SEC(time)
Returns the difference between two time/datetime expressions
rozpocznij naukę
TIMEDIFF(t1, t2)
Returns a datetime value based on a date or datetime value
rozpocznij naukę
TIMESTAMP(date[time], [time])
Returns the number of days between a date and date "0000-00-00"
rozpocznij naukę
TO_DAYS(date)
Returns the week number for a given date
rozpocznij naukę
WEEK(date[time])
Returns the weekday number for a given date
rozpocznij naukę
WEEKDAY(date[time)
Returns the week number for a given date
rozpocznij naukę
WEEKOFYEAR(date[time)
Returns the year part for a given date
rozpocznij naukę
YEAR(date[time)
Returns the year and week number for a given date
rozpocznij naukę
YEARWEEK(date[time)
Returns the absolute value of a number
rozpocznij naukę
ABS(x)
Returns the arc cosine of a number
rozpocznij naukę
ACOS(x)
Returns the arc sine of a number
rozpocznij naukę
ASIN(x)
Returns the arc tangent of one or two numbers
rozpocznij naukę
ATAN(x)
Returns the arc tangent of two numbers
rozpocznij naukę
ATAN2(x, y)
Returns the average value of an expression
rozpocznij naukę
AVG(column)
Returns the smallest integer value that is >= to a number
rozpocznij naukę
CEILING(x)
=CEIL(x)
Returns the cosine of a number
rozpocznij naukę
COS(x)
Returns the cotangent of a number
rozpocznij naukę
COT(x)
Returns the number of records returned by a select query
rozpocznij naukę
COUNT(column)
Converts a value in radians to degrees
rozpocznij naukę
DEGREES(x)
Used for integer division
rozpocznij naukę
DIV
5 div 2 = 2
Returns e raised to the power of a specified number
rozpocznij naukę
EXP(x)
Returns the largest integer value that is <= to a number
rozpocznij naukę
FLOOR(x)
Returns the greatest value of the list of arguments
rozpocznij naukę
GREATEST(arg1, arg2, ...)
Returns the smallest value of the list of arguments
rozpocznij naukę
LEAST(arg1, arg2, ...)
Returns the natural logarithm of a number
rozpocznij naukę
LN(x)
Returns the natural logarithm of a number, or the logarithm of a number to a specified base
rozpocznij naukę
LOG(base, x)
wheras: LOG(x)=LN(x)
Returns the logarithm of a number to base 10
rozpocznij naukę
LOG10(x)
Returns the logarithm of a number to base 2
rozpocznij naukę
LOG2(x)
Returns the maximum value in a set of values
rozpocznij naukę
MAX(column)
Returns the minimum value in a set of values
rozpocznij naukę
MIN(column)
Returns the remainder of a number divided by another number
rozpocznij naukę
x MOD y
=MOD(x,y)=x%y
Returns the value of PI
rozpocznij naukę
PI()
Returns the value of a number raised to the power of another number
rozpocznij naukę
POWER(x, y)
POW(x,y)
Converts a degree value into radians
rozpocznij naukę
RADIANS(x)
Returns a random number x, where x∈⟨0;1)
rozpocznij naukę
RAND()
the same as Python 3 random. random()
Rounds a number to a specified number of decimal places
rozpocznij naukę
ROUND(x,y)
Returns the sign of a number
rozpocznij naukę
SIGN(x)
Returns the sine of a number
rozpocznij naukę
SIN(x)
Returns the square root of a number
rozpocznij naukę
SQRT(x)
Calculates the sum of a set of values
rozpocznij naukę
SUM(column)
Returns the tangent of a number
rozpocznij naukę
TAN(x)
Truncates a number to the specified number of decimal places
rozpocznij naukę
TRUNCATE(x)
Returns a binary representation of a number
rozpocznij naukę
BIN(x)
Attention it AIN'T the same as BINARY()
Converts a value to a binary string
rozpocznij naukę
BINARY value
Converts a value (of any type) into a specified datatype
rozpocznij naukę
CAST(value AS datetype)
Returns the first non-null value in a list
rozpocznij naukę
COALESCE(*args)
Returns the unique connection ID for the current connection
rozpocznij naukę
CONNECTION_ID()
Converts a number from one numeric base system to another
rozpocznij naukę
CONV(n, base, new_base)
Converts a value into the specified datatype or character set
rozpocznij naukę
CONVERT(value, datatype)
Returns the name of the current database
rozpocznij naukę
DATABASE()
Returns a value if a condition is TRUE, or another value if a condition is FALSE
rozpocznij naukę
IF(condition, value1, value2)
Return a specified value if the expression is NULL, otherwise return the expression
rozpocznij naukę
IFNULL(value)
Returns 1 or 0 depending on whether an expression is NULL
rozpocznij naukę
ISNULL(value)
Returns the AUTO_INCREMENT id of the last row that has been inserted or updated in a table
rozpocznij naukę
LAST_INSERT_ID()
Compares two expressions and returns NULL if they are equal. Otherwise, the first expression is returned
rozpocznij naukę
NULLIF(value, value2)
Returns the current MySQL user name and host name
rozpocznij naukę
USER()
=CURRENT_USER()=SYSTEM_USER=SESSION_USER
Returns the current version of the MySQL database
rozpocznij naukę
VERSION()
This will be used to select a database in the MySQL workarea.
rozpocznij naukę
USE Databasename;
Lists out the databases that are accessible by the MySQL DBMS.
rozpocznij naukę
SHOW DATABASES;
Shows the tables in the database once a database has been selected with the use command.
rozpocznij naukę
SHOW TABLES;
Shows the attributes, types of attributes, key information, whether NULL is permitted, defaults, and other information for a table.
rozpocznij naukę
SHOW COLUMNS FROM tablename;
Presents the details of all indexes on the table, including the PRIMARY KEY.
rozpocznij naukę
SHOW INDEX FROM tablename
Reports details of the MySQL DBMS performance and statistics.
rozpocznij naukę
SHOW TABLE STATUS LIKE tablename;
A FIXED length string (can contain letters, numbers, and special characters). The size parameter specifies the column length in characters - can be from 0 to 255. Default is 1
rozpocznij naukę
CHAR(size)
A VARIABLE length string (can contain letters, numbers, and special characters). The size parameter specifies the maximum column length in characters - can be from 0 to 65535
rozpocznij naukę
VARCHAR(size)
Equal to CHAR(), but stores binary byte strings. The size parameter specifies the column length in bytes. Default is 1
rozpocznij naukę
BINARY(size)
Equal to VARCHAR(), but stores binary byte strings. The size parameter specifies the maximum column length in bytes.
rozpocznij naukę
VARBINARY(size)
For BLOBs (Binary Large OBjects). Max length: 255 bytes
rozpocznij naukę
TINYBLOB
Holds a string with a maximum length of 255 characters
rozpocznij naukę
TINYTEXT
Holds a string with a maximum length of 65,535 bytes
rozpocznij naukę
TEXT(size)
For BLOBs (Binary Large OBjects). Holds up to 65,535 bytes of data
rozpocznij naukę
BLOB(size)
Holds a string with a maximum length of 16,777,215 characters
rozpocznij naukę
MEDIUMTEXT
For BLOBs (Binary Large OBjects). Holds up to 16,777,215 bytes of data
rozpocznij naukę
MEDIUMBLOB
Holds a string with a maximum length of 4,294,967,295 characters
rozpocznij naukę
LONGTEXT
For BLOBs (Binary Large OBjects). Holds up to 4,294,967,295 bytes of data
rozpocznij naukę
LONGBLOB
A string object that can have only one value, chosen from a list of possible values.
You can list up to 65535 values in an ENUM list. If a value is inserted that is not in the list, a blank value will be inserted. The values are sorted in the order you enter them
rozpocznij naukę
ENUM(val1, val2, val3, ...)
A string object that can have 0 or more values, chosen from a list of possible values. You can list up to 64 values in a SET list
rozpocznij naukę
SET(val1, val2, val3, ...)
A bit-value type. The number of bits per value is specified in size. The size parameter can hold a value from 1 to 64. The default value for size is 1.
rozpocznij naukę
BIT(size)
A very small integer. Signed range is from -128 to 127. Unsigned range is from 0 to 255. The size parameter specifies the maximum display width (which is 255)
rozpocznij naukę
TINYINT(size)
Zero is considered as false, nonzero values are considered as true.
rozpocznij naukę
BOOL
Equal to BOOL
rozpocznij naukę
BOOLEAN
A small integer. Signed range is from -32768 to 32767. Unsigned range is from 0 to 65535. The size parameter specifies the maximum display width (which is 255)
rozpocznij naukę
SMALLINT(size)
A medium integer. Signed range is from -8388608 to 8388607. Unsigned range is from 0 to 16777215. The size parameter specifies the maximum display width (which is 255)
rozpocznij naukę
MEDIUMINT(size)
A medium integer. Signed range is from -2147483648 to 2147483647. Unsigned range is from 0 to 4294967295. The size parameter specifies the maximum display width (which is 255)
rozpocznij naukę
INT(size)
Equal to INT(size)
rozpocznij naukę
INTEGER(size)
A large integer. Signed range is from -9223372036854775808 to 9223372036854775807. Unsigned range is from 0 to 18446744073709551615. The size parameter specifies the maximum display width (which is 255)
rozpocznij naukę
BIGINT(size)
A floating point number. The total number of digits is specified in size. The number of digits after the decimal point is specified in the d parameter. This syntax is deprecated in MySQL 8.0.17, and it will be removed in future MySQL versions
rozpocznij naukę
FLOAT(size, d)
A floating point number. MySQL uses the p value to determine whether to use FLOAT or DOUBLE for the resulting data type. If p is from 0 to 24, the data type becomes FLOAT(). If p is from 25 to 53, the data type becomes DOUBLE()
rozpocznij naukę
FLOAT(p)
A normal-size floating point number. The total number of digits is specified in size. The number of digits after the decimal point is specified in the d parameter
rozpocznij naukę
DOUBLE(size, d)
An exact fixed-point number. The total number of digits is specified in size.
The number of digits after the decimal point is specified in the d parameter. The maximum number for size is 65. The maximum number for d is 30. The default value for size is 10. The default value for d is 0.
rozpocznij naukę
DECIMAL(size, d)
Equal to DECIMAL(size,d)
rozpocznij naukę
DEC(size, d)
To disable negative numbers.
rozpocznij naukę
UNSIGNED
To add leading zeros, which make all numbers in the column sustain the same length.
rozpocznij naukę
ZEROFILL
A date. Format: YYYY-MM-DD. The supported range is from '1000-01-01' to '9999-12-31'
rozpocznij naukę
DATE
A date and time combination. Format: YYYY-MM-DD hh: mm: ss.
The supported range is from '1000-01-01 00:00:00' to '9999-12-31 23:59:59'. Adding DEFAULT and ON UPDATE in the column definition to get automatic initialization and updating to the current date and time
rozpocznij naukę
DATETIME(fsp)
A timestamp. TIMESTAMP values are stored as the number of seconds since the Unix epoch ('1970-01-01 00:00:00' UTC). Format: YYYY-MM-DD hh: mm: ss.
The supported range is from '1970-01-01 00:00:01' UTC to '2038-01-09 03:14:07' UTC.
rozpocznij naukę
TIMESTAMP(fsp)
A time. Format: hh: mm: ss. The supported range is from '-838:59:59' to '838:59:59'
rozpocznij naukę
TIME(fsp)
A year in four-digit format. Values allowed in four-digit format: 1901 to 2155, and 0000.
rozpocznij naukę
YEAR

Musisz się zalogować, by móc napisać komentarz.