Practical-92

Practical – 92 : MY SQLમાં ટેબલ ડિઝાઈન કરવું  

MySQL ના તમામ ડેટાબેઝનું લીસ્ટ જોવા માટે

ડેટાબેઝની યાદી બતાવવા માટે નીચેની ક્વેરી ચલાવો: ડેટાબેઝ બતાવો; તમે આ સ્ટેટમેન્ટ MySQL કમાન્ડ લાઇન ક્લાયંટ, MySQL શેલ, તેમજ SQL ને સપોર્ટ કરતા કોઈપણ GUI ટૂલમાંથી ચલાવી શકો છો – ઉદાહરણ તરીકે, MySQL માટે dbForge સ્ટુડિયો. MySQL પરિણામોને એક કોલમવાળા ટેબલમાં પરત કરે છે.

કોઈ ડેટાબેઝનો ઉપયોગ કરવા માટે

    1. USE સ્ટેટમેન્ટનો હેતુ:

USE સ્ટેટમેન્ટનો ઉપયોગ વર્તમાન MySQL સત્ર માટે ડિફોલ્ટ ડેટાબેઝ સેટ કરવા માટે થાય છે.

બહુવિધ ડેટાબેઝ સાથે કામ કરતી વખતે આ મહત્વપૂર્ણ છે કારણ કે તમારે MySQL ને દરેક ક્વેરી અથવા ઓપરેશન માટે કયા ડેટાબેઝ સાથે ક્રિયાપ્રતિક્રિયા કરવી તે જણાવવાની જરૂર છે.

    1. વાક્યરચના : કોડ

USE database_name;

ડેટાબેઝના બધા ટેબલ જોવા માટે 

SELECT table_name FROM INFORMATION_SCHEMA. TABLES WHERE table_type = ‘BASE TABLE’ SELECT name FROM sys. …

— This returns all the tables in the database system. …

— Lists all the tables in all databases SELECT table_name FROM information_schema.

નવું ટેબલ બનાવવા માટે

CREATE TABLE table_name (

    column1_name datatype constraints,

    column2_name datatype constraints,

    …

    columnN_name datatype constraints

);

ટેબલનું સ્ટ્રક્ચર જોવા માટે

SQL માં કોષ્ટકનું માળખું જોવા માટે, તમે DESCRIBE સ્ટેટમેન્ટનો ઉપયોગ કરી શકો છો અથવા INFORMATION_SCHEMA કેટલોગમાંથી માહિતી ક્વેરી કરી શકો છો. DESCRIBE સ્ટેટમેન્ટ એ કોષ્ટકના કૉલમ નામો, ડેટા પ્રકારો અને અન્ય ગુણધર્મો મેળવવાનો એક સરળ રસ્તો છે. વૈકલ્પિક રીતે, તમે વધુ વિગતવાર માહિતી મેળવવા માટે INFORMATION_SCHEMA.COLUMNS સામે ક્વેરીનો ઉપયોગ કરી શકો છો.

ટેબલમાં નવી ફિલ્ડ ઉમેરવા માટે

The ALTER TABLE statement is used to add, delete, or modify columns in an existing table. The ALTER TABLE statement is also used to add and drop various constraints on an existing table.

ટેબલના ફિલ્ડની ડેટાટાઇપ બદલવા માટે

The basic syntax for changing a column type using the ALTER TABLE command: ALTER TABLE table_name MODIFY COLUMN column_name new_data_type; In this syntax: table_name is the name of the table you want to modify.

ટેબલમાંથી ફિલ્ડને દુર કરવા માટે

Deleting a Column in MySQL1 ALTER TABLE table_name 2 DROP [COLUMN] column_name; Note that the COLUMN keyword is optional. For more details about this query, read our article on the MySQL ALTER TABLE statement.

ડેટાબેઝમાંથી ટેબલને દુર કરવા માટે

To remove a table in MySQL, use the DROP TABLE statement. The basic command syntax is as follows:

DROP TABLE table_name;