How to get table size in MySQL

How to get table size in MySQL: We can get this information from the schema ‘information_schema’.

Query:

SELECT table_name AS 'Table', round(((data_length + index_length) / 1024 / 1024), 2) 'Size in MB' FROM information_schema.TABLES WHERE table_schema = "sakila" AND table_name = "rental";

Difference between delete and truncate

Delete: Whenever we are using delete from tablename, then automatically deleted data internally stored in buffer. We can get it back by using rollback command.

How to execute script file in MySQL

script file contains list of commands saved in with .sql/.txt or other extension. To import or export file in MySQL, use must be granted FILE permission.

Steps to execute script file in MySQL:

1. Create a file(.sql extension): We are going to get list of users in MySQL using the file

prvr@ubuntu:~$ cat > getlistofusers.sql select user from mysql.user; prvr@ubuntu:~$ ls -ltrh *getlist* -rw-rw-r-- 1 prvr prvr 29 Sep 6 17:41 getlistofusers.sql

Lock and Unlock user account in Sybase

What happens if account is locked?

1. User can not login.
2. If any schedule jobs with specified login.

When login can be locked.

1. When maximum failed login attempts reached.
2. If password expires
3. System Security Officer locks login
4. Accounts are locked due to account inacrivity.

How to know account is locked or not?

Change password in Sybase

When password needs to changed?
1. If we forgot password.
2. When password expiration level reached(If customized). By default option is set to ever expiry password.

What are the prerequisites to change password?
1. Caller password(Whoever is changing password of other user or him/herself)
2. Only System Security Officer can change the password.

Syntax to change Password:

How to change Working Directory in R

When we open RStudio or R gui it uses Default Working Directory.

getwd(): It is used to know the current working directory
setwd(): It is used to change the current working directory to another.

When RStudio started following things will happen:

Executes the .Rprofile (if any) from the default working directory.
Loads the .RData file (if any) from the default working directory into the workspace.

When RStudio exits: There are changes to the workspace, a prompt asks whether these changes should be saved to the .RData file in the current working directory.

How to change Working Directory in R

head and tail functions in R

head and tails function in R used to get first or last parts of a vector,table, matrix, data frame or function.

head() function: Used to get first parts of vector,table, matrix, data frame or function. By default, it will provide first 6 rows.
tail() function: Used to get last parts of vector,table, matrix, data frame or function. By default, it will provide last 6 rows.

Examples for head function in R:

Sybase Interview Questions

How to stop Sybase(ASE) Server?

1> shutdown RUN_Servername
2> go

How to stop Sybase backup server?

1> shutdown SYB_BACKUP
2> go

How to start Sybase ASE server?

To start the server Sybase ASE server, navigate to …./ASExxx/install/. Then, run following command
1> startserver –f RUN_servername
2> go

How to start Sybase Backup server?

To start the server Sybase backup server, navigate to …./ASExxx/install/. Then, run following command
1> startserver –f RUN_servername_back
2> go

How to stop Sybase ASE server forcefully?

1>shutdown with no wait
2>go

How to find out who initiated shutdown command in Sybase?

This can be checked from errorlog. To check that, run the following command, it will give the log name. Then check the last lines of the log.

1> select @@errorlog
2> go

What will happens when we run “shutdown with no wait”?

It disables the logins, does not issue checkpoint, and it terminates current transactions (processes).

What are the different roles available in Sybase?

There are six roles available in sybase.
sa_role
sso_role
oper_role
sybase_ts_role
navigator_role
replication_role
dtm_tm_role
ha_role
mon_role
js_admin_role
messaging_role
js_client_role
js_user_role
webservices_role
keycustodian_role
sa_serverprivs_role

How to check the last update statics performed date?
select moddate from sysstatistics where id=object_id(“accounts”)

Will be added some more questions soon.

How to stop Sybase server forcefully

Sometimes it is required to shutdown the Sybase ASE server forcefully. This can be done with “shutdown with no wait” command. This disables the logins, does not issue checkpoint, and it terminates current transactions (processes).

To stop Sybase server forcefully:

Powered by k2schools