Browsed by
Author: priya

How to see table’s field formats or description of table

How to see table’s field formats or description of table

mysql> describe tablename; In MySQL, you can use the DESC or DESCRIBE statement to see the description of a table, including the field formats. Here’s an example: sql DESCRIBE your_table_name; or sql DESC your_table_name; Replace “your_table_name” with the actual name of the table you want to describe. This will provide information about the columns, their data types, whether they allow NULL values, and any additional attributes. For example: sql DESCRIBE employees; This will show you the structure and details of…

Read More Read More

How to see all the tables from a database of mysql server

How to see all the tables from a database of mysql server

mysql> show tables; To see all the tables in a MySQL database, you can use the following SQL query: sql SHOW TABLES; This query will display a list of all tables in the currently selected database. If you want to see tables from a specific database, you can switch to that database using the USE statement before running the SHOW TABLES query. For example: sql USE your_database_name; SHOW TABLES; Replace your_database_name with the name of the database you want to…

Read More Read More

How Switch (select or use) to a database

How Switch (select or use) to a database

mysql> use databasename; In MySQL, you can switch (select or use) to a different database using the USE statement. Here’s the syntax: sql USE database_name; Replace database_name with the name of the database you want to switch to. This statement sets the default database for the current session. For example, if you want to switch to a database called “mydatabase,” you would execute: sql USE mydatabase; After executing this statement, any subsequent SQL statements will be executed in the context…

Read More Read More

How to list or view all databases from the mysql server

How to list or view all databases from the mysql server

mysql> show databases. To list or view all databases in MySQL, you can use the following SQL command: sql SHOW DATABASES; When you run this command in the MySQL command-line interface or any MySQL client tool, it will display a list of all the databases available on the MySQL server.

How you will Create a database on the mysql server with unix shell

How you will Create a database on the mysql server with unix shell

mysql> create database databasename; To create a MySQL database on a server using the Unix shell, you can use the mysqladmin or mysql command-line tools. Here’s an example using the mysql command: Open a terminal on your Unix-based system. Log in to the MySQL server using the following command. You will be prompted to enter the MySQL user password. bash mysql -u username -p Replace “username” with your MySQL username. Once you are logged in, you can create a new…

Read More Read More

How to do login in mysql with unix shell

How to do login in mysql with unix shell

By below method if password is pass and user name is root # [mysql dir]/bin/mysql -h hostname -u root -p pass To log in to MySQL using the Unix shell, you can use the mysql command along with the appropriate options. Here’s the general syntax: bash mysql -u your_username -p Replace your_username with your MySQL username. After running this command, you will be prompted to enter your MySQL password. Once you provide the correct password, you’ll be logged into the…

Read More Read More

Interview Scenario on MySQL:

Interview Scenario on MySQL:

Interview Scenario on MySQL: There is a table named SAMPLE, and we want to delete all the data from the table. Which is better option? delete * from SAMPLE truncate table SAMPLE In delete cursor is on the current location, data is deleted from the table but memory is not released by the table, by which searching and sorting operation may take so much time. While, in truncate cursor is on the starting location, data is deleted permanently and memory is released for…

Read More Read More

Import data into MySQL from any file

Import data into MySQL from any file

How to Import data into MySQL from any file: Mysql –u root <db.sql (for database and tables) Mysql –u root <data.sql (for data into tables) To import data into MySQL from a file, you can use the LOAD DATA INFILE statement. Here’s a basic example of how to use it: sql LOAD DATA INFILE ‘path/to/your/file.csv’ INTO TABLE your_table FIELDS TERMINATED BY ‘,’ ENCLOSED BY ‘”‘ LINES TERMINATED BY ‘\n’ IGNORE 1 LINES; — if your file has a header and…

Read More Read More